Skip to content

Commit

Permalink
pythongh-123341: Support tkinter.Event type subcript (python#123353)
Browse files Browse the repository at this point in the history
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
  • Loading branch information
yowoda and Eclips4 authored Sep 1, 2024
1 parent 64af2b2 commit 42a8189
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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.

0 comments on commit 42a8189

Please sign in to comment.