gh-107422: fix outdated docs example code of typing.TypedDict#107423
gh-107422: fix outdated docs example code of typing.TypedDict#107423ghubrakesh wants to merge 0 commit intopython:mainfrom ghubrakesh:main
Conversation
Doc/library/typing.rst
Outdated
| T = TypeVar('T') | ||
| class XT(X, Generic[T]): pass # raises TypeError | ||
| class XT(X, Generic[T]): pass # OK (Non-TypeDict class but Generic) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Thanks for the PR! However, since the next paragraph starts with "A
TypedDictcan 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?
There was a problem hiding this comment.
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? :)
There was a problem hiding this comment.
Yes, I am opening a new one with the changes you are asking for.
|
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 |

Outdated example code of typing.TypedDict
Changed the docs where,
📚 Documentation preview 📚: https://cpython-previews--107423.org.readthedocs.build/