diff --git a/pyproject.toml b/pyproject.toml index fcd9474fda63..87ac9c3cf7d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,7 @@ test = [ "PyVisa-sim>=0.6.0", "sphinx>=4.5.0", # sphinx extension tests "types-jsonschema>=4.16.0", - "types-networkx >= 3.1", # Version should match the networkx requirment + "types-networkx >= 3.6.1.20260303", # minimum version required for correct edge_subgraph types "types_requests>=0.1.8", "types-tabulate>=0.1.0", "types-tqdm>=4.64.6", diff --git a/requirements.txt b/requirements.txt index 8ab10d83db67..83529d441479 100644 --- a/requirements.txt +++ b/requirements.txt @@ -453,7 +453,7 @@ traitlets==5.14.3 # nbsphinx types-jsonschema==4.26.0.20260202 # via qcodes (pyproject.toml) -types-networkx==3.6.1.20260210 +types-networkx==3.6.1.20260303 # via qcodes (pyproject.toml) types-pytz==2025.2.0.20251108 # via pandas-stubs diff --git a/src/qcodes/dataset/descriptions/dependencies.py b/src/qcodes/dataset/descriptions/dependencies.py index 5d23129520fa..4fa4e635ff45 100644 --- a/src/qcodes/dataset/descriptions/dependencies.py +++ b/src/qcodes/dataset/descriptions/dependencies.py @@ -10,7 +10,7 @@ from collections import defaultdict from copy import deepcopy from itertools import chain, product -from typing import TYPE_CHECKING, Any, Literal, cast +from typing import TYPE_CHECKING, Any, Literal import networkx as nx from typing_extensions import deprecated @@ -150,9 +150,7 @@ def _dependency_subgraph(self) -> nx.DiGraph[str]: for edge in self.graph.edges if self.graph.edges[edge]["interdep_type"] == "depends_on" ] - # the type annotations does not currently encode that edge_subgraph of a DiGraph - # is a DiGraph - return cast("nx.DiGraph[str]", self.graph.edge_subgraph(depends_on_edges)) + return self.graph.edge_subgraph(depends_on_edges) @property def _inference_subgraph(self) -> nx.DiGraph[str]: @@ -161,9 +159,7 @@ def _inference_subgraph(self) -> nx.DiGraph[str]: for edge in self.graph.edges if self.graph.edges[edge]["interdep_type"] == "inferred_from" ] - # the type annotations does not currently encode that edge_subgraph of a DiGraph - # is a DiGraph - return cast("nx.DiGraph[str]", self.graph.edge_subgraph(inferred_from_edges)) + return self.graph.edge_subgraph(inferred_from_edges) def extend( self,