diff options
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 97744a8..5054e28 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -906,6 +906,12 @@ class singledispatchmethod: Registers a new implementation for the given *cls* on a *generic_method*. """ + # bpo-39679: in Python <= 3.9, classmethods and staticmethods don't + # inherit __annotations__ of the wrapped function (fixed in 3.10+ as + # a side-effect of bpo-43682) but we need that for annotation-derived + # singledispatches. So we add that just-in-time here. + if isinstance(cls, (staticmethod, classmethod)): + cls.__annotations__ = getattr(cls.__func__, '__annotations__', {}) return self.dispatcher.register(cls, func=method) def __get__(self, obj, cls=None): |