Skip to content

Commit 42a8189

Browse files
yowodaEclips4
andauthored
gh-123341: Support tkinter.Event type subcript (#123353)
Co-authored-by: Kirill Podoprigora <[email protected]>
1 parent 64af2b2 commit 42a8189

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Lib/test/test_genericalias.py

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
from weakref import WeakSet, ReferenceType, ref
5858
import typing
5959
from typing import Unpack
60+
try:
61+
from tkinter import Event
62+
except ImportError:
63+
Event = None
6064

6165
from typing import TypeVar
6266
T = TypeVar('T')
@@ -139,6 +143,8 @@ class BaseTest(unittest.TestCase):
139143
if ValueProxy is not None:
140144
generic_types.extend((ValueProxy, DictProxy, ListProxy, ApplyResult,
141145
MPSimpleQueue, MPQueue, MPJoinableQueue))
146+
if Event is not None:
147+
generic_types.append(Event)
142148

143149
def test_subscriptable(self):
144150
for t in self.generic_types:

Lib/tkinter/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ def __repr__(self):
295295
''.join(' %s=%s' % (k, attrs[k]) for k in keys if k in attrs)
296296
)
297297

298+
__class_getitem__ = classmethod(types.GenericAlias)
299+
298300

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

0 commit comments

Comments
 (0)