Closed CodeMouse92 closed 10 hours ago
Bug Report
As of Python 3.13, it is possible to return a value from a simple coroutine (generator): https://github.com/python/cpython/issues/104770
This is supported by the type hints. However, Mypy does not consider the generator/coroutine annotation to determine the return type of close().
close()
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.13&gist=c1ef127cdbc6359a99c346b0ee15c8b5
Expected Behavior
If the simple coroutine (generator) f is annotated to return a type (e.g. int), then the call to f.close() should be recognized as returning an int.
f
int
f.close()
Actual Behavior
error: "close" of "Generator" does not return a value (it only ever returns None) [func-returns-value]
Your Environment
mypy.ini
[tool.mypy] strict = true enable_incomplete_feature = ["NewGenericSyntax"] # only needed until PEP 695 is fully supported
Thanks! This looks like an issue with Generator's stubs in typeshed. I opened https://github.com/python/typeshed/pull/13127
Generator
Bug Report
As of Python 3.13, it is possible to return a value from a simple coroutine (generator): https://github.com/python/cpython/issues/104770
This is supported by the type hints. However, Mypy does not consider the generator/coroutine annotation to determine the return type of
close()
.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.13&gist=c1ef127cdbc6359a99c346b0ee15c8b5
Expected Behavior
If the simple coroutine (generator)
f
is annotated to return a type (e.g.int
), then the call tof.close()
should be recognized as returning anint
.Actual Behavior
Your Environment
mypy.ini
(and other config files):