Skip to content

bpo-45684: Add __class_getitem__ method to singledispatchmethod #29355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,8 @@ def _method(*args, **kwargs):
def __isabstractmethod__(self):
return getattr(self.func, '__isabstractmethod__', False)

__class_getitem__ = classmethod(GenericAlias)


################################################################################
### cached_property() - computed once per instance, cached as attribute
Expand Down
7 changes: 5 additions & 2 deletions Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from contextlib import AbstractContextManager, AbstractAsyncContextManager
from contextvars import ContextVar, Token
from dataclasses import Field
from functools import partial, partialmethod, cached_property
from functools import (
partial, partialmethod, cached_property, singledispatchmethod
)
from mailbox import Mailbox, _PartialFile
try:
import ctypes
Expand Down Expand Up @@ -55,7 +57,8 @@ class BaseTest(unittest.TestCase):
FileInput,
OrderedDict, Counter, UserDict, UserList,
Pattern, Match,
partial, partialmethod, cached_property,
partial, partialmethod,
cached_property, singledispatchmethod,
AbstractContextManager, AbstractAsyncContextManager,
Awaitable, Coroutine,
AsyncIterable, AsyncIterator,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``__class_getitem__`` method to ``functools.singledispatchmethod``.