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

gh-118647: Add defaults to typing.Generator and typing.AsyncGenerator #118648

Merged
merged 4 commits into from
May 6, 2024

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented May 6, 2024

@Daverball
Copy link

It might be worth considering also updating ContextManager and AsyncContextManager to match what I did in python/typeshed#11048 for AbstractContextManager and AbstractAsyncContextManager, now that you've laid the necessary groundwork for defaults in _SpecialGenericAlias.

But we can also save it for a follow-up PR, if you'd prefer that. A change in typeshed doesn't make sense until we test 3.13 to the CI.

@JelleZijlstra JelleZijlstra marked this pull request as ready for review May 6, 2024 16:55
@JelleZijlstra
Copy link
Member Author

@Daverball Possibly, but note that we're one day away from the feature freeze for Python 3.13. I can spend some time on it later today, but please open a separate issue first.

@AlexWaygood if you have time, could you review this PR that just adds defaults for Generator and AsyncGenerator?

Doc/library/typing.rst Outdated Show resolved Hide resolved
Doc/library/typing.rst Outdated Show resolved Hide resolved
@graingert
Copy link
Contributor

typing.Generator and typing.AsyncGenerator are deprecated, why are they getting new features?

@mikeshardmind
Copy link

mikeshardmind commented May 6, 2024

typing.Generator and typing.AsyncGenerator are deprecated, why are they getting new features?

I would hope this isn't a real blocker here. From a user standpoint, users are told collections.abc variants are meant to behave identically. (they are actually documented as a deprecated alias and not as a separate object)

Deprecated alias to collections.abc.Generator.

(https://docs.python.org/3/library/typing.html#typing.Generator)

If this deprecation results in them not being equivalent anymore, you've broken the documented idea of them being equivalent.

Lib/typing.py Outdated Show resolved Hide resolved
Lib/typing.py Outdated Show resolved Hide resolved
@JelleZijlstra JelleZijlstra enabled auto-merge (squash) May 6, 2024 22:04
@JelleZijlstra JelleZijlstra merged commit 8419f01 into python:main May 6, 2024
33 checks passed
@JelleZijlstra JelleZijlstra deleted the gendef branch May 6, 2024 23:15
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
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 this pull request may close these issues.

6 participants