Skip to content

Commit d8ce092

Browse files
authored
Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. (#130460)
In relation to #109544 which changed this behavior. Signed-off-by: Daniel Sperber <[email protected]>
1 parent 89d8b2d commit d8ce092

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
@@ -8479,6 +8479,22 @@ class TD2(TD1):
84798479

84808480
self.assertIs(TD2.__total__, True)
84818481

8482+
def test_total_with_assigned_value(self):
8483+
class TD(TypedDict):
8484+
__total__ = "some_value"
8485+
8486+
self.assertIs(TD.__total__, True)
8487+
8488+
class TD2(TypedDict, total=True):
8489+
__total__ = "some_value"
8490+
8491+
self.assertIs(TD2.__total__, True)
8492+
8493+
class TD3(TypedDict, total=False):
8494+
__total__ = "some value"
8495+
8496+
self.assertIs(TD3.__total__, False)
8497+
84828498
def test_optional_keys(self):
84838499
class Point2Dor3D(Point2D, total=False):
84848500
z: int

0 commit comments

Comments
 (0)