Skip to content

Commit 6abec03

Browse files
[3.13] Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. (GH-130460) (#130462)
Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. (GH-130460) In relation to GH-109544 which changed this behavior. (cherry picked from commit d8ce092) Signed-off-by: Daniel Sperber <github.blurry@9ox.net> Co-authored-by: Daraan <github.blurry@9ox.net>
1 parent c68a872 commit 6abec03

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_typing.py

+16
Original file line numberDiff line numberDiff line change
@@ -8356,6 +8356,22 @@ class TD2(TD1):
83568356

83578357
self.assertIs(TD2.__total__, True)
83588358

8359+
def test_total_with_assigned_value(self):
8360+
class TD(TypedDict):
8361+
__total__ = "some_value"
8362+
8363+
self.assertIs(TD.__total__, True)
8364+
8365+
class TD2(TypedDict, total=True):
8366+
__total__ = "some_value"
8367+
8368+
self.assertIs(TD2.__total__, True)
8369+
8370+
class TD3(TypedDict, total=False):
8371+
__total__ = "some value"
8372+
8373+
self.assertIs(TD3.__total__, False)
8374+
83598375
def test_optional_keys(self):
83608376
class Point2Dor3D(Point2D, total=False):
83618377
z: int

0 commit comments

Comments
 (0)