Skip to content

Commit 00e8ee7

Browse files
DaraanJelleZijlstra
andcommitted
Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 8184ac6 commit 00e8ee7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/test_typing_extensions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,6 +4148,17 @@ def test_total(self):
41484148
self.assertEqual(Options.__required_keys__, frozenset())
41494149
self.assertEqual(Options.__optional_keys__, {'log_level', 'log_path'})
41504150

4151+
def test_total_inherits_non_total(self):
4152+
class TD1(TypedDict, total=False):
4153+
a: int
4154+
4155+
self.assertIs(TD1.__total__, False)
4156+
4157+
class TD2(TD1):
4158+
b: str
4159+
4160+
self.assertIs(TD2.__total__, True)
4161+
41514162
def test_optional_keys(self):
41524163
class Point2Dor3D(Point2D, total=False):
41534164
z: int

src/typing_extensions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,6 @@ def __new__(cls, name, bases, ns, *, total=True, closed=False):
10291029
tp_dict.__optional_keys__ = frozenset(optional_keys)
10301030
tp_dict.__readonly_keys__ = frozenset(readonly_keys)
10311031
tp_dict.__mutable_keys__ = frozenset(mutable_keys)
1032-
if not hasattr(tp_dict, '__total__'):
1033-
tp_dict.__total__ = total
10341032
tp_dict.__closed__ = closed
10351033
tp_dict.__extra_items__ = extra_items_type
10361034
return tp_dict

0 commit comments

Comments
 (0)