From 67b769f5157c9dad1c7dd6b24e067b9fdab5b35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Thu, 10 Dec 2020 23:49:05 +0200 Subject: bpo-42059: Fix required/optional keys for TypedDict(..., total=False) (GH-22736) --- Lib/typing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/typing.py') diff --git a/Lib/typing.py b/Lib/typing.py index 46c54c4069..148a505dad 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -2043,14 +2043,14 @@ def TypedDict(typename, fields=None, /, *, total=True, **kwargs): raise TypeError("TypedDict takes either a dict or keyword arguments," " but not both") - ns = {'__annotations__': dict(fields), '__total__': total} + ns = {'__annotations__': dict(fields)} try: # Setting correct module is necessary to make typed dict classes pickleable. ns['__module__'] = sys._getframe(1).f_globals.get('__name__', '__main__') except (AttributeError, ValueError): pass - return _TypedDictMeta(typename, (), ns) + return _TypedDictMeta(typename, (), ns, total=total) _TypedDict = type.__new__(_TypedDictMeta, 'TypedDict', (), {}) TypedDict.__mro_entries__ = lambda bases: (_TypedDict,) -- cgit v1.2.1