Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. #130460

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

Merged
merged 3 commits into from
Feb 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: Assignment to a __total__ key in class body
In relation to #109544 which changed this behavior.

Signed-off-by: Daniel Sperber <github.blurry@9ox.net>
  • Loading branch information
Daraan committed Feb 22, 2025
commit 27af527b1c747b138e7595e0cd3498fb0956e428
16 changes: 16 additions & 0 deletions 16 Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8478,6 +8478,22 @@ class TD2(TD1):
b: str

self.assertIs(TD2.__total__, True)

def test_total_with_assigned_value(self):
class TD(TypedDict):
__total__ = "some_value"

self.assertIs(TD.__total__, True)

class TD2(TypedDict, total=True):
__total__ = "some_value"

self.assertIs(TD2.__total__, True)

class TD3(TypedDict, total=False):
picnixz marked this conversation as resolved.
Show resolved Hide resolved
__total__ = "some value"

self.assertIs(TD3.__total__, False)

def test_optional_keys(self):
class Point2Dor3D(Point2D, total=False):
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.