Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@
assert_type(degree_view(""), int)
assert_type(degree_view([""]), DegreeView[str])
assert_type(degree_view({""}), DegreeView[str])

# Test scalar attributes with name in set_node_attributes and set_edge_attributes
nx.set_node_attributes(G, 5, "some_name")

Check failure on line 28 in stubs/networkx/@tests/test_cases/check_tricky_function_params-py312.py

View workflow job for this annotation

GitHub Actions / pyright: regression tests (Linux, 3.13)

Type of "set_node_attributes" is partially unknown   Type of "set_node_attributes" is "Overload[(G: Graph[_Node@set_node_attributes, dict[str, Any], dict[str, Any]], values: SupportsItems[_Node@set_node_attributes, object], name: str, *, backend: Unknown | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_node_attributes, dict[str, Any], dict[str, Any]], values: SupportsItems[_Node@set_node_attributes, SupportsKeysAndGetItem[Any, Any] | Iterable[tuple[Any, Any]]], name: None = None, *, backend: Unknown | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_node_attributes, dict[str, Any], dict[str, Any]], values: object, name: str, *, backend: Unknown | None = None, **backend_kwargs: Unknown) -> None]" (reportUnknownMemberType)
nx.set_node_attributes(G, {1: "val"}, "some_name")

Check failure on line 29 in stubs/networkx/@tests/test_cases/check_tricky_function_params-py312.py

View workflow job for this annotation

GitHub Actions / pyright: regression tests (Linux, 3.13)

Type of "set_node_attributes" is partially unknown   Type of "set_node_attributes" is "Overload[(G: Graph[_Node@set_node_attributes, dict[str, Any], dict[str, Any]], values: SupportsItems[_Node@set_node_attributes, object], name: str, *, backend: Unknown | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_node_attributes, dict[str, Any], dict[str, Any]], values: SupportsItems[_Node@set_node_attributes, SupportsKeysAndGetItem[Any, Any] | Iterable[tuple[Any, Any]]], name: None = None, *, backend: Unknown | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_node_attributes, dict[str, Any], dict[str, Any]], values: object, name: str, *, backend: Unknown | None = None, **backend_kwargs: Unknown) -> None]" (reportUnknownMemberType)
nx.set_edge_attributes(G, 10, "weight")

Check failure on line 30 in stubs/networkx/@tests/test_cases/check_tricky_function_params-py312.py

View workflow job for this annotation

GitHub Actions / pyright: regression tests (Linux, 3.13)

Type of "set_edge_attributes" is partially unknown   Type of "set_edge_attributes" is "Overload[(G: Graph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: SupportsItems[tuple[_Node@set_edge_attributes, _Node@set_edge_attributes], Any], name: str, *, backend: str | None = None, **backend_kwargs: Unknown) -> None, (G: MultiGraph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: dict[tuple[_Node@set_edge_attributes, _Node@set_edge_attributes, Any], Any], name: str, *, backend: str | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: object, name: str, *, backend: str | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: Unknown, name: None = None, *, backend: str | None = None, **backend_kwargs: Unknown) -> None]" (reportUnknownMemberType)
nx.set_edge_attributes(G, {(1, 2): 10}, "weight")

Check failure on line 31 in stubs/networkx/@tests/test_cases/check_tricky_function_params-py312.py

View workflow job for this annotation

GitHub Actions / pyright: regression tests (Linux, 3.13)

Type of "set_edge_attributes" is partially unknown   Type of "set_edge_attributes" is "Overload[(G: Graph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: SupportsItems[tuple[_Node@set_edge_attributes, _Node@set_edge_attributes], Any], name: str, *, backend: str | None = None, **backend_kwargs: Unknown) -> None, (G: MultiGraph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: dict[tuple[_Node@set_edge_attributes, _Node@set_edge_attributes, Any], Any], name: str, *, backend: str | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: object, name: str, *, backend: str | None = None, **backend_kwargs: Unknown) -> None, (G: Graph[_Node@set_edge_attributes, dict[str, Any], dict[str, Any]], values: Unknown, name: None = None, *, backend: str | None = None, **backend_kwargs: Unknown) -> None]" (reportUnknownMemberType)
5 changes: 4 additions & 1 deletion stubs/networkx/networkx/classes/function.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def to_directed(graph): ...
def to_undirected(graph): ...
def create_empty_copy(G: Graph[_Node], with_data: bool = True): ...

# incomplete: Can "Any scalar value" be enforced?
@overload
def set_node_attributes(
G: Graph[_Node],
Expand All @@ -101,6 +100,8 @@ def set_node_attributes(
backend=None,
**backend_kwargs,
) -> None: ...
@overload
def set_node_attributes(G: Graph[_Node], values: object, name: str, *, backend=None, **backend_kwargs) -> None: ...

@_dispatchable
def get_node_attributes(G: Graph[_Node], name: str, default=None) -> dict[_Node, Incomplete]: ...
Expand All @@ -126,6 +127,8 @@ def set_edge_attributes(
**backend_kwargs,
) -> None: ...
@overload
def set_edge_attributes(G: Graph[_Node], values: object, name: str, *, backend: str | None = None, **backend_kwargs) -> None: ...
@overload
def set_edge_attributes(G: Graph[_Node], values, name: None = None, *, backend: str | None = None, **backend_kwargs) -> None: ...

@_dispatchable
Expand Down
Loading