self.assertEqual(Options.__required_keys__, frozenset())
self.assertEqual(Options.__optional_keys__, {'log_level', 'log_path'})
+ def test_total_inherits_non_total(self):
+ class TD1(TypedDict, total=False):
+ a: int
+
+ self.assertIs(TD1.__total__, False)
+
+ class TD2(TD1):
+ b: str
+
+ self.assertIs(TD2.__total__, True)
+
def test_optional_keys(self):
class Point2Dor3D(Point2D, total=False):
z: int
tp_dict.__annotations__ = annotations
tp_dict.__required_keys__ = frozenset(required_keys)
tp_dict.__optional_keys__ = frozenset(optional_keys)
- if not hasattr(tp_dict, '__total__'):
- tp_dict.__total__ = total
+ tp_dict.__total__ = total
return tp_dict
__call__ = dict # static method