Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Python 3.13.0 generator.close() return value (Python issue #104770) #13128

Closed
CodeMouse92 opened this issue Nov 26, 2024 · 1 comment · Fixed by #13127
Closed

Comments

@CodeMouse92
Copy link

CodeMouse92 commented Nov 26, 2024

Bug Report

As of Python 3.13, it is possible to return a value from a simple coroutine (generator): python/cpython#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 to f.close() should be recognized as returning an int.

Actual Behavior

error: "close" of "Generator" does not return a value (it only ever returns None)  [func-returns-value]

Your Environment

  • Mypy version used: 1.13.0
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
strict = true
enable_incomplete_feature = ["NewGenericSyntax"]  # only needed until PEP 695 is fully supported
  • Python version used: 3.13.0
@brianschubert
Copy link
Contributor

Thanks! This looks like an issue with Generator's stubs in typeshed. I opened #13127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants