Skip to content

Commit bcffe74

Browse files
authored
networkx Final and Literal from python-type-stubs (#14601)
1 parent c901b9b commit bcffe74

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Incomplete, SupportsLenAndGetItem
2-
from collections.abc import Callable, Mapping
3-
from typing import Any, TypeVar
2+
from collections.abc import Callable, Iterable, Mapping
3+
from typing import Any, Literal, TypeVar
44

55
from networkx.classes.digraph import DiGraph
66
from networkx.classes.graph import Graph, _Node
@@ -57,7 +57,7 @@ def simulated_annealing_tsp(
5757
@_dispatchable
5858
def threshold_accepting_tsp(
5959
G: Graph[_Node],
60-
init_cycle,
60+
init_cycle: Literal["greedy"] | Iterable[Incomplete],
6161
weight: str | None = "weight",
6262
source=None,
6363
threshold: int | None = 1,
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from _typeshed import Incomplete
22
from collections.abc import Iterable
3+
from typing import Literal
34

45
from networkx.classes.graph import Graph, _Node
56
from networkx.utils.backends import _dispatchable
@@ -8,5 +9,9 @@ __all__ = ["average_degree_connectivity"]
89

910
@_dispatchable
1011
def average_degree_connectivity(
11-
G: Graph[_Node], source="in+out", target="in+out", nodes: Iterable[Incomplete] | None = None, weight: str | None = None
12+
G: Graph[_Node],
13+
source: Literal["in+out", "out", "in"] = "in+out",
14+
target: Literal["in+out", "out", "in"] = "in+out",
15+
nodes: Iterable[Incomplete] | None = None,
16+
weight: str | None = None,
1217
) -> dict[Incomplete, int | float]: ...

stubs/networkx/networkx/readwrite/gexf.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from _typeshed import Incomplete
22
from collections.abc import Generator
3+
from typing import Final, Literal
34

45
from networkx.utils.backends import _dispatchable
56

@@ -17,7 +18,7 @@ class GEXF:
1718
xml_type: Incomplete
1819
python_type: Incomplete
1920
def construct_types(self) -> None: ...
20-
convert_bool: Incomplete
21+
convert_bool: Final[dict[Literal["true", "false", "True", "False", "0", 0, "1", 1], bool]]
2122
NS_GEXF: Incomplete
2223
NS_VIZ: Incomplete
2324
NS_XSI: Incomplete

stubs/networkx/networkx/readwrite/graphml.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Incomplete
22
from collections.abc import Generator
3-
from typing import Final
3+
from typing import Final, Literal
44

55
from networkx.utils.backends import _dispatchable
66

@@ -49,7 +49,7 @@ class GraphML:
4949
xml_type: Incomplete
5050
python_type: Incomplete
5151
def construct_types(self) -> None: ...
52-
convert_bool: Incomplete
52+
convert_bool: Final[dict[Literal["true", "false", "0", 0, "1", 1], bool]]
5353
def get_xml_type(self, key): ...
5454

5555
class GraphMLWriter(GraphML):

0 commit comments

Comments
 (0)