diff options
author | Ethan Smith <ethan@ethanhs.me> | 2020-04-14 04:53:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 04:53:04 (GMT) |
commit | cecf049673da6a24435acd1a6a3b34472b323c97 (patch) | |
tree | 10ade472188b307c3a8874124a2ce5696a1da4c8 /Lib/functools.py | |
parent | 584a3cfda4d7a65ea0c1ea1ee541378bb7be46ca (diff) | |
download | cpython-cecf049673da6a24435acd1a6a3b34472b323c97.zip cpython-cecf049673da6a24435acd1a6a3b34472b323c97.tar.gz cpython-cecf049673da6a24435acd1a6a3b34472b323c97.tar.bz2 |
bpo-39481: Make functools.cached_property, partial, partialmethod generic (#19427)
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 70fcec5..f05b106 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -20,6 +20,7 @@ from collections import namedtuple # import types, weakref # Deferred to single_dispatch() from reprlib import recursive_repr from _thread import RLock +from types import GenericAlias ################################################################################ @@ -656,6 +657,9 @@ class partialmethod(object): def __isabstractmethod__(self): return getattr(self.func, "__isabstractmethod__", False) + __class_getitem__ = classmethod(GenericAlias) + + # Helper functions def _unwrap_partial(func): @@ -1208,3 +1212,5 @@ class cached_property: ) raise TypeError(msg) from None return val + + __class_getitem__ = classmethod(GenericAlias) |