From 27af527b1c747b138e7595e0cd3498fb0956e428 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Sat, 22 Feb 2025 16:52:56 +0100 Subject: [PATCH 1/2] test: Assignment to a __total__ key in class body In relation to #109544 which changed this behavior. Signed-off-by: Daniel Sperber --- Lib/test/test_typing.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index f002d28df60e9c..aac25406b0719d 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -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): + __total__ = "some value" + + self.assertIs(TD3.__total__, False) def test_optional_keys(self): class Point2Dor3D(Point2D, total=False): From 2e7d1d8908bf58207d7a57776965341df5af07f1 Mon Sep 17 00:00:00 2001 From: Daniel Sperber Date: Sat, 22 Feb 2025 17:22:56 +0100 Subject: [PATCH 2/2] style: run pre-commit --- Lib/test/test_typing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index aac25406b0719d..591fb860eee1e0 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -8478,7 +8478,7 @@ class TD2(TD1): b: str self.assertIs(TD2.__total__, True) - + def test_total_with_assigned_value(self): class TD(TypedDict): __total__ = "some_value" @@ -8487,7 +8487,7 @@ class TD(TypedDict): class TD2(TypedDict, total=True): __total__ = "some_value" - + self.assertIs(TD2.__total__, True) class TD3(TypedDict, total=False):