https://github.com/python/cpython/commit/d8ce092fe4e98fec414f4e60cfc958b3ac3ec9a3
commit: d8ce092fe4e98fec414f4e60cfc958b3ac3ec9a3
branch: main
author: Daraan <[email protected]>
committer: JelleZijlstra <[email protected]>
date: 2025-02-22T09:34:22-08:00
summary:

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]>

files:
M Lib/test/test_typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index f002d28df60e9c..591fb860eee1e0 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -8479,6 +8479,22 @@ class TD2(TD1):
 
         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

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to