...for "purposes such as commentary, criticism, news reporting, and scholarly reports"? Sure.
For a commercial product? Best check with your lawyer...
In general it is not fair use if you are using the material for the same scope as the original author[0] or if you are doing it just to namedrop/quote/omage the original.
It is possible to argue that a snippet can be too small to be protected, but that would not be because of fair use.
[0] Suppose that some Author B did as above and copied a snippet of code in their docstring to exlain buggy behaviour of a library they were reimplementing. If you are then trying to reimplement B's libary you can copy the same snippet B copied, but you likely cannot copy the paragraph written by B where they explain the how and the why of the bug.
We aren't talking verbatim generation of entire packages of code here, are we? Code snippets are surely covered under fair use?