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]: Correct typing for suppressing/forwarding contexts #143

Closed
maxfischer2781 opened this issue Jun 3, 2024 · 0 comments · Fixed by #145
Closed

[Typing]: Correct typing for suppressing/forwarding contexts #143

maxfischer2781 opened this issue Jun 3, 2024 · 0 comments · Fixed by #145
Assignees

Comments

@maxfischer2781
Copy link
Owner

There was a recent update to the typing spec that codified the meaning of return types for (async) contexts: -> bool/-> Literal[True] now mean the context may suppress exceptions, and any other annotations means exceptions are not suppressed. Notably, if a context does always return False in exit it should still not be -> bool to indicate the exception propagates.

At least one annotation is not correct with this scheme:

async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool:
await self.thing.aclose()
return False

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.

1 participant