chore: 批量优化代码与配置,完善类型注解
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
This type stub file was generated by pyright.
|
||||
"""
|
||||
|
||||
__all__ = ["TopologicalSorter", "CycleError"]
|
||||
from typing import Any, Generator
|
||||
|
||||
__all__ = ["CycleError", "TopologicalSorter"]
|
||||
_NODE_OUT = ...
|
||||
_NODE_DONE = ...
|
||||
class _NodeInfo:
|
||||
__slots__ = ...
|
||||
def __init__(self, node) -> None:
|
||||
...
|
||||
|
||||
|
||||
class _NodeInfo:
|
||||
__slots__: list[str]
|
||||
|
||||
def __init__(self, node) -> None: ...
|
||||
|
||||
class CycleError(ValueError):
|
||||
"""Subclass of ValueError raised by TopologicalSorterif cycles exist in the graph
|
||||
@@ -22,14 +23,13 @@ class CycleError(ValueError):
|
||||
next node in the list. In the reported list, the first and the last node will be
|
||||
the same, to make it clear that it is cyclic.
|
||||
"""
|
||||
...
|
||||
|
||||
...
|
||||
|
||||
class TopologicalSorter:
|
||||
"""Provides functionality to topologically sort a graph of hashable nodes"""
|
||||
def __init__(self, graph=...) -> None:
|
||||
...
|
||||
|
||||
|
||||
def __init__(self, graph=...) -> None: ...
|
||||
def add(self, node, *predecessors) -> None:
|
||||
"""Add a new node and its predecessors to the graph.
|
||||
|
||||
@@ -45,8 +45,9 @@ class TopologicalSorter:
|
||||
|
||||
Raises ValueError if called after "prepare".
|
||||
"""
|
||||
|
||||
...
|
||||
|
||||
|
||||
def prepare(self) -> None:
|
||||
"""Mark the graph as finished and check for cycles in the graph.
|
||||
|
||||
@@ -55,8 +56,9 @@ class TopologicalSorter:
|
||||
progress. After a call to this function, the graph cannot be modified and
|
||||
therefore no more nodes can be added using "add".
|
||||
"""
|
||||
|
||||
...
|
||||
|
||||
|
||||
def get_ready(self) -> tuple[Any, ...]:
|
||||
"""Return a tuple of all the nodes that are ready.
|
||||
|
||||
@@ -67,8 +69,9 @@ class TopologicalSorter:
|
||||
|
||||
Raises ValueError if called without calling "prepare" previously.
|
||||
"""
|
||||
|
||||
...
|
||||
|
||||
|
||||
def is_active(self) -> bool:
|
||||
"""Return True if more progress can be made and ``False`` otherwise.
|
||||
|
||||
@@ -79,11 +82,10 @@ class TopologicalSorter:
|
||||
|
||||
Raises ValueError if called without calling "prepare" previously.
|
||||
"""
|
||||
|
||||
...
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
...
|
||||
|
||||
|
||||
def __bool__(self) -> bool: ...
|
||||
def done(self, *nodes) -> None:
|
||||
"""Marks a set of nodes returned by "get_ready" as processed.
|
||||
|
||||
@@ -95,9 +97,10 @@ class TopologicalSorter:
|
||||
graph by using "add" or if called without calling "prepare" previously or if
|
||||
node has not yet been returned by "get_ready".
|
||||
"""
|
||||
|
||||
...
|
||||
|
||||
def static_order(self) -> Generator[Any, Any, None]:
|
||||
|
||||
def static_order(self) -> Generator[Any]:
|
||||
"""Returns an iterable of nodes in a topological order.
|
||||
|
||||
The particular order that is returned may depend on the specific
|
||||
@@ -106,7 +109,5 @@ class TopologicalSorter:
|
||||
Using this method does not require to call "prepare" or "done". If any
|
||||
cycle is detected, :exc:`CycleError` will be raised.
|
||||
"""
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user