From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 22 Feb 2025 18:33:20 +0000 (+0100) Subject: [3.13] Add test checking value of a TypedDict's __total__ attribute when there is... X-Git-Tag: v3.13.3~221 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6abec03aeff0a52d12780000923af0cee5ef1b6c;p=thirdparty%2FPython%2Fcpython.git [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 d8ce092fe4e98fec414f4e60cfc958b3ac3ec9a3) Signed-off-by: Daniel Sperber Co-authored-by: Daraan --- diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 89a32c7a1a0d..9d4993196628 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -8356,6 +8356,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