gh-118660: Add second type parameter to (Async)ContextManager#118681
gh-118660: Add second type parameter to (Async)ContextManager#118681JelleZijlstra merged 8 commits intopython:mainfrom
Conversation
|
cc @Daverball |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Misc/NEWS.d/next/Library/2024-05-06-18-13-02.gh-issue-118660.n01Vb7.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Misc/NEWS.d/next/Library/2024-05-06-18-13-02.gh-issue-118660.n01Vb7.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood
left a comment
There was a problem hiding this comment.
LGTM. Some "optional" inline suggestions below that might alleviate @Daverball's concerns a bit:
Misc/NEWS.d/next/Library/2024-05-06-18-13-02.gh-issue-118660.n01Vb7.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This is in response to: python/cpython#118681
…ython#118681) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
) This is in response to: python/cpython#118681
typing.ContextManagerandtyping.AbstractContextManager#118660