10000 Outdated example code of typing.TypedDict · Issue #107422 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Outdated example code of typing.TypedDict #107422

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
wanglc02 opened this issue Jul 29, 2023 · 1 comment
Closed

Outdated example code of typing.TypedDict #107422

wanglc02 opened this issue Jul 29, 2023 · 1 comment
Labels
docs Documentation in the Doc dir topic-typing

Comments

@wanglc02
Copy link
wanglc02 commented Jul 29, 2023

Documentation

https://docs.python.org/3.12/library/typing.html#typing.TypedDict

Changed in version 3.11: Added support for generic TypedDicts.

The text description has already changed, too:
A TypedDict cannot inherit from a non-TypedDict class, except for Generic. For example:

class X(TypedDict):
    x: int

class Y(TypedDict):
    y: int

class Z(object): pass  # A non-TypedDict class

class XY(X, Y): pass  # OK

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

T = TypeVar('T')
class XT(X, Generic[T]): pass  # raises TypeError

On the last line of the above code, # raises TypeError should be # OK. I have tested this in version 3.12. It is OK.

Linked PRs

@wanglc02 wanglc02 added the docs Documentation in the Doc dir label Jul 29, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 29, 2023
…pythonGH-107436)

(cherry picked from commit 89fd4f4)

Co-authored-by: Rakesh Sabale <102187286+ghubrakesh@users.noreply.github.com>
AlexWaygood pushed a commit that referenced this issue Jul 29, 2023
GH-107436) (#107437)

gh-107422: Remove outdated `TypedDict` example from typing docs (GH-107436)
(cherry picked from commit 89fd4f4)

Co-authored-by: Rakesh Sabale <102187286+ghubrakesh@users.noreply.github.com>
AlexWaygood added a commit that referenced this issue Jul 29, 2023
#107436) (#107438)

gh-107422: Remove outdated `TypedDict` example from typing docs (#107436)

Co-authored-by: Rakesh Sabale <102187286+ghubrakesh@users.noreply.github.com>
7739
@AlexWaygood
Copy link
Member

This has now been fixed, and backported to 3.12 and 3.11. Thanks @wanglc02 for opening the issue, and thanks @ghubrakesh for the PR fixing it!

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 topic-typing
Projects
None yet
Development

No branches or pull requests

2 participants
0