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

Typing spec update for exceptions / context managers #27

Closed
5 tasks done
erictraut opened this issue Apr 20, 2024 · 3 comments
Closed
5 tasks done

Typing spec update for exceptions / context managers #27

erictraut opened this issue Apr 20, 2024 · 3 comments
Labels

Comments

@erictraut
Copy link
Collaborator

erictraut commented Apr 20, 2024

I'd like to request that the TC consider adoption of a new (small) chapter in the typing spec that spells out the type checking behaviors for context managers — specifically, how to use the return type of __exit__ to determine whether a context manager suppresses exceptions.

Links to PR & Discussion
The PR can be found here. It incorporates feedback from PR reviewers.

The discussion can be found here.

TC Sign-off

  • Eric
  • Guido
  • Jelle
  • Rebecca
  • Shantanu

Current Type Checker Behaviors
The specified behavior is consistent with the current behavior of mypy and pyright. It is also consistent with assumptions that are baked into typeshed stubs. I haven't done detailed testing on pyre or pytype, but given that they leverage typeshed stubs, they likely conform.

@gvanrossum
Copy link
Member

(While I didn't approve the PR yet, my feedback there is just two nits, and even if you didn't address those I'm happy with this chapter, as it describes existing practice.)

@erictraut
Copy link
Collaborator Author

@gvanrossum, thanks for the feedback. I've incorporated your suggestions.

@rchen152, let me know if you have any concerns or feedback.

@rchen152
Copy link
Collaborator

No concerns from me.

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

No branches or pull requests

4 participants