Skip to content

Commit 3cb9731

Browse files
JacobHayesblurb-it[bot]isidentical
authored
bpo-45359: Support TopologicalSorter type subscript (GH-28714)
* Support TopologicalSorter type subscript * πŸ“œπŸ€– Added by blurb_it. * Add TopologicalSorter to GenericAlias tests * Update Misc/NEWS.d/next/Library/2021-10-03-22-27-35.bpo-45359.LX_uxe.rst Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Batuhan Taskaya <[email protected]>
1 parent f893bb2 commit 3cb9731

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

β€ŽLib/graphlib.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from types import GenericAlias
2+
13
__all__ = ["TopologicalSorter", "CycleError"]
24

35
_NODE_OUT = -1
@@ -244,3 +246,5 @@ def static_order(self):
244246
node_group = self.get_ready()
245247
yield from node_group
246248
self.done(*node_group)
249+
250+
__class_getitem__ = classmethod(GenericAlias)

β€ŽLib/test/test_genericalias.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from contextvars import ContextVar, Token
1414
from dataclasses import Field
1515
from functools import partial, partialmethod, cached_property
16+
from graphlib import TopologicalSorter
1617
from mailbox import Mailbox, _PartialFile
1718
try:
1819
import ctypes
@@ -56,6 +57,7 @@ class BaseTest(unittest.TestCase):
5657
OrderedDict, Counter, UserDict, UserList,
5758
Pattern, Match,
5859
partial, partialmethod, cached_property,
60+
TopologicalSorter,
5961
AbstractContextManager, AbstractAsyncContextManager,
6062
Awaitable, Coroutine,
6163
AsyncIterable, AsyncIterator,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement :pep:`585` for :class:`graphlib.TopologicalSorter`.

0 commit comments

Comments
Β (0)