-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Bug Report
When stubgen encounters a function with a nested generator-function, that generator type is used for the return type of the function, even if the function itself does not return a generator.
To Reproduce
- Create a file
generator.py:def some_function(): def generator(): yield "a" return 5
- Run
stubgen generator.py.
Expected Behavior
The function in the generated type stub has a "regular" return type.
from collections.abc import Generator
from typing import Any
def some_function() -> Any: ... # or intActual Behavior
The stub function has a Generator[None, None, Any] type.
from collections.abc import Generator
from typing import Any
def some_function() -> Generator[None, None, Any]: ...Your Environment
- Mypy version used: 0.930
- Mypy command-line flags:
stubgen generator.py - Mypy configuration options from
mypy.ini(and other config files): - - Python version used: 3.9.9
- Operating system and version: macOS 12.1