8000 gh-107422: fix outdated docs example code of typing.TypedDict by ghubrakesh · Pull Request #107423 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-107422: fix outdated docs example code of typing.TypedDict #107423

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

Closed
wants to merge 0 commits into from
Closed

gh-107422: fix outdated docs example code of typing.TypedDict #107423

wants to merge 0 commits into from

Conversation

ghubrakesh
Copy link
Contributor
@ghubrakesh ghubrakesh commented Jul 29, 2023

Outdated example code of typing.TypedDict

Changed the docs where,

- class XT(X, Generic[T]): pass  # raises TypeError
+ class XT(X, Generic[T]): pass  # OK (Non-TypeDict class but Generic)

📚 Documentation preview 📚: https://cpython-previews--107423.org.readthedocs.build/

@ghost
Copy link
ghost commented Jul 29, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir skip news labels Jul 29, 2023
@AlexWaygood AlexWaygood changed the title Outdated example code of typing.TypedDict #107422 gh-107422: fix outdated docs example code of typing.TypedDict Jul 29, 2023
Comment on lines 2332 to 2333
T = TypeVar('T')
class XT(X, Generic[T]): pass # raises TypeError
class XT(X, Generic[T]): pass # OK (Non-TypeDict class but Generic)
Copy link
Member
@AlexWaygood AlexWaygood Jul 29, 2023

Choose a reason for hiding this comment

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

Thanks for the PR! However, since the next paragraph starts with "A TypedDict can be generic", and goes on to give several examples of generic TypedDicts, I think a better solution would be to just delete this example altogether

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the PR! However, since the next paragraph starts with "A TypedDict can be generic", and goes on to give several examples of generic TypedDicts, I think a better solution would be to just delete this example altogether

Hello @AlexWaygood, thanks for considering my PR, I am a bit confused, Should I delete all the examples and lines which mentions 'generic TypedDict' because either way it's not compatible with python 3.12 onwards.
What I mean is, should I delete all these lines which are crossed in the following picture?

changes

Copy link
Member
@AlexWaygood AlexWaygood Jul 29, 2023

Choose a reason for hiding this comment

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

What I mean is, should I delete all these lines which are crossed in the following picture?

No, most of those lines are accurate documentation for Python 3.13, which is what the CPython main branch is :)

I think the only change required for this issue is to do this:

--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -2329,9 +2329,6 @@ types.

       class XZ(X, Z): pass  # raises TypeError

-      T = TypeVar('T')
-      class XT(X, Generic[T]): pass  # raises TypeError
-
    A ``TypedDict`` can be generic::

The typing module changed quite a lot in Python 3.12 due to the implementation of PEP-695, so a lot of the lines you're pointing to were introduced in Python 3.12, but don't exist on the 3.11 branch of CPython. These three lines that I'm suggesting we delete, however, exist on Python main, Python 3.12 and Python 3.11, and are incorrect on all three branches. If you make a PR to the main branch deleting these lines, we can merge it, and then backport it to the 3.12 and 3.11 branches.

It looks like you might have closed this PR by accident. Would you like to open a new one? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I am opening a new one with the changes you are asking for.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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

Successfully merging this pull request may close these issues.

3 participants
0