Skip to content

bpo-45359: Support TopologicalSorter type subscript #28714

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

Merged
merged 4 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/graphlib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from types import GenericAlias

__all__ = ["TopologicalSorter", "CycleError"]

_NODE_OUT = -1
Expand Down Expand Up @@ -244,3 +246,5 @@ def static_order(self):
node_group = self.get_ready()
yield from node_group
self.done(*node_group)

__class_getitem__ = classmethod(GenericAlias)
2 changes: 2 additions & 0 deletions Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implement :pep:`585` for :class:`graphlib.TopologicalSorter`.