diff options
-rw-r--r-- | Lib/graphlib.py | 4 | ||||
-rw-r--r-- | Lib/test/test_genericalias.py | 2 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-10-03-22-27-35.bpo-45359.LX_uxe.rst | 1 |
3 files changed, 7 insertions, 0 deletions
diff --git a/Lib/graphlib.py b/Lib/graphlib.py index 1c5d9a4..6365456 100644 --- a/Lib/graphlib.py +++ b/Lib/graphlib.py @@ -1,3 +1,5 @@ +from types import GenericAlias + __all__ = ["TopologicalSorter", "CycleError"] _NODE_OUT = -1 @@ -244,3 +246,5 @@ class TopologicalSorter: node_group = self.get_ready() yield from node_group self.done(*node_group) + + __class_getitem__ = classmethod(GenericAlias) diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py index 0daaff0..706cc5e 100644 --- a/Lib/test/test_genericalias.py +++ b/Lib/test/test_genericalias.py @@ -13,6 +13,7 @@ from contextlib import AbstractContextManager, AbstractAsyncContextManager from contextvars import ContextVar, Token from dataclasses import Field from functools import partial, partialmethod, cached_property +from graphlib import TopologicalSorter from mailbox import Mailbox, _PartialFile try: import ctypes @@ -56,6 +57,7 @@ class BaseTest(unittest.TestCase): OrderedDict, Counter, UserDict, UserList, Pattern, Match, partial, partialmethod, cached_property, + TopologicalSorter, AbstractContextManager, AbstractAsyncContextManager, Awaitable, Coroutine, AsyncIterable, AsyncIterator, diff --git a/Misc/NEWS.d/next/Library/2021-10-03-22-27-35.bpo-45359.LX_uxe.rst b/Misc/NEWS.d/next/Library/2021-10-03-22-27-35.bpo-45359.LX_uxe.rst new file mode 100644 index 0000000..6f5c97f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-10-03-22-27-35.bpo-45359.LX_uxe.rst @@ -0,0 +1 @@ +Implement :pep:`585` for :class:`graphlib.TopologicalSorter`.
\ No newline at end of file |