https://github.com/python/cpython/commit/42a818912bdb367c4ec2b7d58c18db35f55ebe3b commit: 42a818912bdb367c4ec2b7d58c18db35f55ebe3b branch: main author: Yoda <[email protected]> committer: AlexWaygood <[email protected]> date: 2024-09-01T12:47:07+01:00 summary:
gh-123341: Support `tkinter.Event` type subcript (#123353) Co-authored-by: Kirill Podoprigora <[email protected]> files: A Misc/NEWS.d/next/Library/2024-08-27-10-30-37.gh-issue-123341.5e-fjt.rst M Lib/test/test_genericalias.py M Lib/tkinter/__init__.py diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py index 04122fbdd0ae80..12564b423493aa 100644 --- a/Lib/test/test_genericalias.py +++ b/Lib/test/test_genericalias.py @@ -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') @@ -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: diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 2e5affb15e3f61..dd7b3e138f4236 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -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 diff --git a/Misc/NEWS.d/next/Library/2024-08-27-10-30-37.gh-issue-123341.5e-fjt.rst b/Misc/NEWS.d/next/Library/2024-08-27-10-30-37.gh-issue-123341.5e-fjt.rst new file mode 100644 index 00000000000000..61561eeb807023 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-08-27-10-30-37.gh-issue-123341.5e-fjt.rst @@ -0,0 +1 @@ +Add :meth:`~object.__class_getitem__` to :class:`!tkinter.Event` for type subscript support at runtime. Patch by Adonis Rakateli. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
