]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45359: Support TopologicalSorter type subscript (GH-28714)
authorJacob Hayes <jacob.r.hayes@gmail.com>
Wed, 8 Dec 2021 18:52:57 +0000 (13:52 -0500)
committerGitHub <noreply@github.com>
Wed, 8 Dec 2021 18:52:57 +0000 (20:52 +0200)
* 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 <isidentical@gmail.com>
Lib/graphlib.py
Lib/test/test_genericalias.py
Misc/NEWS.d/next/Library/2021-10-03-22-27-35.bpo-45359.LX_uxe.rst [new file with mode: 0644]

index 1c5d9a413c944d376f9a9b29f8a86fa90e5a31d5..636545648e12d3bd530b80127dd358e21ef5c9de 100644 (file)
@@ -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)
index 0daaff099a868d7d23fdef7e79cd93a6b39049cc..706cc5ea1af2f0ea869bd36241de6a359025e1c9 100644 (file)
@@ -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 (file)
index 0000000..6f5c97f
--- /dev/null
@@ -0,0 +1 @@
+Implement :pep:`585` for :class:`graphlib.TopologicalSorter`.
\ No newline at end of file