Skip to content
Merged
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
6 changes: 6 additions & 0 deletions Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
from weakref import WeakSet, ReferenceType, ref
import typing
from typing import Unpack
try:
from tkinter import Event
except ImportError:
Event = None

from typing import TypeVar
T = TypeVar('T')
Expand Down Expand Up @@ -139,6 +143,8 @@ class BaseTest(unittest.TestCase):
if ValueProxy is not None:
generic_types.extend((ValueProxy, DictProxy, ListProxy, ApplyResult,
MPSimpleQueue, MPQueue, MPJoinableQueue))
if Event is not None:
generic_types.append(Event)

def test_subscriptable(self):
for t in self.generic_types:
Expand Down
2 changes: 2 additions & 0 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def __repr__(self):
''.join(' %s=%s' % (k, attrs[k]) for k in keys if k in attrs)
)

__class_getitem__ = classmethod(types.GenericAlias)


_support_default_root = True
_default_root = None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :meth:`~object.__class_getitem__` to :class:`!tkinter.Event` for type subscript support at runtime. Patch by Adonis Rakateli.