Add __slots__ to third-party packages using stubdefaulter (#14619)

This commit is contained in:
Jelle Zijlstra
2025-08-21 15:38:13 -07:00
committed by GitHub
parent 573b57d8da
commit ca44e4c45d
135 changed files with 675 additions and 25 deletions
@@ -5,11 +5,13 @@ from networkx.utils.backends import _dispatchable
__all__ = ["CurrentEdge", "Level", "GlobalRelabelThreshold", "build_residual_network", "detect_unboundedness", "build_flow_dict"]
class CurrentEdge:
__slots__ = ("_edges", "_it", "_curr")
def __init__(self, edges) -> None: ...
def get(self): ...
def move_to_next(self) -> None: ...
class Level:
__slots__ = ("active", "inactive")
active: Incomplete
inactive: Incomplete
@@ -34,6 +34,26 @@ class ConflictPair:
def lowest(self, planarity_state): ...
class LRPlanarity:
__slots__ = [
"G",
"roots",
"height",
"lowpt",
"lowpt2",
"nesting_depth",
"parent_edge",
"DG",
"adjs",
"ordered_adjs",
"ref",
"side",
"S",
"stack_bottom",
"lowpt_edge",
"left_ref",
"right_ref",
"embedding",
]
G: Incomplete
roots: Incomplete
height: Incomplete
+13 -4
View File
@@ -21,6 +21,7 @@ __all__ = [
]
class AtlasView(Mapping[_T, dict[_U, _V]]):
__slots__ = ("_atlas",)
def __getstate__(self) -> dict[str, Mapping[_T, dict[_U, _V]]]: ...
def __setstate__(self, state: dict[str, Mapping[_T, dict[_U, _V]]]) -> None: ...
def __init__(self, d: Mapping[_T, dict[_U, _V]]) -> None: ...
@@ -29,10 +30,14 @@ class AtlasView(Mapping[_T, dict[_U, _V]]):
def __getitem__(self, key: _T) -> dict[_U, _V]: ...
def copy(self) -> dict[_T, dict[_U, _V]]: ...
class AdjacencyView(AtlasView[_T, _U, _V]): ...
class MultiAdjacencyView(AdjacencyView[_T, _U, _V]): ...
class AdjacencyView(AtlasView[_T, _U, _V]):
__slots__ = ()
class MultiAdjacencyView(AdjacencyView[_T, _U, _V]):
__slots__ = ()
class UnionAtlas(Mapping[_T, dict[_U, _V]]):
__slots__ = ("_succ", "_pred")
def __init__(self, succ: AtlasView[_T, _U, _V], pred: AtlasView[_T, _U, _V]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
@@ -40,14 +45,18 @@ class UnionAtlas(Mapping[_T, dict[_U, _V]]):
def copy(self) -> Self: ...
class UnionAdjacency(Mapping[_T, dict[_U, _V]]):
__slots__ = ("_succ", "_pred")
def __init__(self, succ: AdjacencyView[_T, _U, _V], pred: AdjacencyView[_T, _U, _V]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __getitem__(self, key: _T) -> dict[_U, _V]: ...
def copy(self) -> Self: ...
class UnionMultiInner(UnionAtlas[_T, _U, _V]): ...
class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V]): ...
class UnionMultiInner(UnionAtlas[_T, _U, _V]):
__slots__ = ()
class UnionMultiAdjacency(UnionAdjacency[_T, _U, _V]):
__slots__ = ()
class FilterAtlas(Mapping[_T, _U]):
NODE_OK: Callable[[_T], bool]
@@ -35,6 +35,7 @@ __all__ = [
]
class NodeView(Mapping[_Node, dict[str, Any]], AbstractSet[_Node]):
__slots__ = ("_nodes",)
def __init__(self, graph: Graph[_Node]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_Node]: ...
@@ -47,6 +48,7 @@ class NodeView(Mapping[_Node, dict[str, Any]], AbstractSet[_Node]):
def data(self, data: bool | str = True, default=None) -> Self: ...
class NodeDataView(AbstractSet[_Node]):
__slots__ = ("_nodes", "_data", "_default")
def __init__(self, nodedict: Mapping[str, Incomplete], data: bool | str = False, default=None) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[tuple[_Node, Incomplete]]: ... # type: ignore[override]
@@ -73,24 +75,33 @@ class OutMultiDegreeView(DiDegreeView[_Node]): ...
class EdgeViewABC(ABC): ...
class OutEdgeDataView(EdgeViewABC, Generic[_Node, _D]):
__slots__ = ("_viewer", "_nbunch", "_data", "_default", "_adjdict", "_nodes_nbrs", "_report")
def __init__(self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default=None) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_D]: ...
def __contains__(self, e: _Edge[_Node]) -> bool: ...
class EdgeDataView(OutEdgeDataView[_Node, _D]): ...
class InEdgeDataView(OutEdgeDataView[_Node, _D]): ...
class EdgeDataView(OutEdgeDataView[_Node, _D]):
__slots__ = ()
class InEdgeDataView(OutEdgeDataView[_Node, _D]):
__slots__ = ()
class OutMultiEdgeDataView(OutEdgeDataView[_Node, _D]):
__slots__ = ("keys",)
keys: bool
def __init__(
self, viewer, nbunch: _NBunch[_Node] = None, data: bool = False, *, default=None, keys: bool = False
) -> None: ...
class MultiEdgeDataView(OutEdgeDataView[_Node, _D]): ...
class InMultiEdgeDataView(OutEdgeDataView[_Node, _D]): ...
class MultiEdgeDataView(OutEdgeDataView[_Node, _D]):
__slots__ = ()
class InMultiEdgeDataView(OutEdgeDataView[_Node, _D]):
__slots__ = ()
class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], EdgeViewABC, Generic[_Node]):
__slots__ = ("_adjdict", "_graph", "_nodes_nbrs")
def __init__(self, G: Graph[_Node]) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[tuple[_Node, _Node]]: ...
@@ -131,6 +142,7 @@ class OutEdgeView(AbstractSet[Incomplete], Mapping[Incomplete, Incomplete], Edge
) -> OutEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
class EdgeView(OutEdgeView[_Node]):
__slots__ = ()
dataview = EdgeDataView
# Have to override parent's overloads with the proper return type based on dataview
@overload
@@ -167,6 +179,7 @@ class EdgeView(OutEdgeView[_Node]):
) -> EdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
class InEdgeView(OutEdgeView[_Node]):
__slots__ = ()
dataview = InEdgeDataView
# Have to override parent's overloads with the proper return type based on dataview
@overload
@@ -203,6 +216,7 @@ class InEdgeView(OutEdgeView[_Node]):
) -> InEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
class OutMultiEdgeView(OutEdgeView[_Node]):
__slots__ = ()
def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override]
def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override]
dataview = OutMultiEdgeDataView
@@ -266,6 +280,7 @@ class OutMultiEdgeView(OutEdgeView[_Node]):
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, _U]]: ...
class MultiEdgeView(OutMultiEdgeView[_Node]):
__slots__ = ()
dataview = MultiEdgeDataView # type: ignore[assignment]
# Have to override parent's overloads with the proper return type based on dataview
@overload # type: ignore[override] # Has an additional `keys` keyword argument
@@ -328,6 +343,7 @@ class MultiEdgeView(OutMultiEdgeView[_Node]):
) -> MultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, _U]]: ...
class InMultiEdgeView(OutMultiEdgeView[_Node]):
__slots__ = ()
dataview = InMultiEdgeDataView # type: ignore[assignment]
# Have to override parent's overloads with the proper return type based on dataview
@overload # type: ignore[override]
+2
View File
@@ -4,6 +4,7 @@ __all__ = ["MinHeap", "PairingHeap", "BinaryHeap"]
class MinHeap:
class _Item:
__slots__ = ("key", "value")
key: Incomplete
value: Incomplete
def __init__(self, key, value) -> None: ...
@@ -20,6 +21,7 @@ class MinHeap:
class PairingHeap(MinHeap):
class _Node(MinHeap._Item):
__slots__ = ("left", "next", "prev", "parent")
left: Incomplete
next: Incomplete
prev: Incomplete
@@ -4,6 +4,7 @@ from collections.abc import Iterator
__all__ = ["MappedQueue"]
class _HeapElement:
__slots__ = ["priority", "element", "_hash"]
priority: Incomplete
element: Incomplete
def __init__(self, priority, element) -> None: ...