I've been using inspect.isgeneratorfunction on my code successfully. Here's a simple example:
def f():
for _ in range(5):
yield "Hello World!"
inspect.isgeneratorfunction(f), inspect.isgeneratorfunction(blah.f) (when I store f in blah.py), and inspect.isgeneratorfunction(foo.f) (when blah is imported as foo), among others, all correctly return True as expected.
However, when I apply this to the following function from networkx, which has a similar structure, results are wrong: inspect.isgeneratorfunction(networkx.biconnected_components) returns False.
@not_implemented_for("directed")
def biconnected_components(G):
"""(docstring trimmed)"""
for comp in _biconnected_dfs(G, components=True):
yield set(chain.from_iterable(comp))
What am I missing?
Possibly relevant:
- I'm using Python 3.11.2 and networkx 2.8.8
networkx.biconnected_componentsactually points tonetworkx.algorithms.components.biconnected.biconnected_components