diff options
author | larryhastings <larry@hastings.org> | 2021-04-30 03:09:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-30 03:09:08 (GMT) |
commit | 2f2b69855d6524e15d12c15ddc0adce629e7de84 (patch) | |
tree | aac6542c35708f45670fc5ae027a9fc1802e8498 /Lib/typing.py | |
parent | dbe60ee09dc5a624cfb78dff61ecf050a5b3f105 (diff) | |
download | cpython-2f2b69855d6524e15d12c15ddc0adce629e7de84.zip cpython-2f2b69855d6524e15d12c15ddc0adce629e7de84.tar.gz cpython-2f2b69855d6524e15d12c15ddc0adce629e7de84.tar.bz2 |
bpo-43901: Lazy-create an empty annotations dict in all unannotated user classes and modules (#25623)
Change class and module objects to lazy-create empty annotations dicts on demand. The annotations dicts are stored in the object's `__dict__` for backwards compatibility.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r-- | Lib/typing.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index d409517..ff96434 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1677,6 +1677,8 @@ def get_type_hints(obj, globalns=None, localns=None, include_extras=False): else: base_globals = globalns ann = base.__dict__.get('__annotations__', {}) + if isinstance(ann, types.GetSetDescriptorType): + ann = {} base_locals = dict(vars(base)) if localns is None else localns if localns is None and globalns is None: # This is surprising, but required. Before Python 3.10, |