Skip to content

gh-118660: Add second type parameter to (Async)ContextManager #118681

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

Merged
merged 8 commits into from
May 7, 2024

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented May 7, 2024

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir awaiting core review labels May 7, 2024
@JelleZijlstra
Copy link
Member Author

cc @Daverball

@JelleZijlstra JelleZijlstra requested a review from AlexWaygood as a code owner May 7, 2024 01:14

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe put a little bit more emphasis on the new type parameter being optional. While it defaulting to bool | None implies that, it's maybe a little bit too subtle for user-facing documentation, especially for a new feature in 3.13.

We could also consider changing the notation from Generic[T_co, ExitT_co] to Generic[T_co, ExitT_co = bool | None], so its behavior can be inferred just from this header, similar to function signatures, even if that is not valid syntax, it's similar to PEP-695 notation, while retaining the implicit reference to Generic within the typing module.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that syntax with Generic but didn't use it here because it's a SyntaxError. Switching to PEP 695 syntax might be nice but I think it causes problems with Sphinx. In any case, this is something we can adjust after the beta.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we have to use an old version of Sphinx to keep Linux redistributors happy, and old versions of Sphinx don't know about PEP-695 syntax so they do weird things with the syntax highlighting

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some "optional" inline suggestions below that might alleviate @Daverball's concerns a bit:

@JelleZijlstra JelleZijlstra enabled auto-merge (squash) May 7, 2024 13:52
@JelleZijlstra JelleZijlstra merged commit 71080b8 into python:main May 7, 2024
33 checks passed
Daverball added a commit to Daverball/typeshed that referenced this pull request May 7, 2024
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
JelleZijlstra pushed a commit to python/typeshed that referenced this pull request May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants