Skip to content
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

gh-123341: Support tkinter.Event type subcript #123353

Merged
merged 9 commits into from
Sep 1, 2024
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.
Loading