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 <github.blurry@9ox.net>
This commit is contained in:
Daraan 2025-02-22 18:34:22 +01:00 committed by GitHub
parent 89d8b2d14b
commit d8ce092fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8479,6 +8479,22 @@ class TypedDictTests(BaseTestCase):
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):
__total__ = "some value"
self.assertIs(TD3.__total__, False)
def test_optional_keys(self):
class Point2Dor3D(Point2D, total=False):
z: int