refactor: switch to basedpyright, remove pydantic-settings
- Replace pyright with basedpyright in devenv.nix (custom hook) - Add basedpyright to devenv packages - Fix all basedpyright warnings: add DiGraph[str] type args, annotate class attributes, narrow SyncResponse, handle unused call results, suppress unavoidable Any from yaml.safe_load and untyped blackforest - Replace pydantic-settings[yaml] with direct pyyaml dependency - Update CLAUDE.md to reflect basedpyright and dependency changes
This commit is contained in:
parent
f71af1cfaf
commit
7ab25d49cb
11 changed files with 58 additions and 59 deletions
|
|
@ -9,7 +9,7 @@ import networkx as nx
|
|||
from bulkgen.config import ProjectConfig
|
||||
|
||||
|
||||
def build_graph(config: ProjectConfig, project_dir: Path) -> nx.DiGraph:
|
||||
def build_graph(config: ProjectConfig, project_dir: Path) -> nx.DiGraph[str]:
|
||||
"""Build a dependency DAG from the project configuration.
|
||||
|
||||
Nodes are filenames: target names (keys in ``config.targets``) and
|
||||
|
|
@ -19,7 +19,7 @@ def build_graph(config: ProjectConfig, project_dir: Path) -> nx.DiGraph:
|
|||
Raises :class:`ValueError` if a dependency is neither a defined target
|
||||
nor an existing file, or if the graph contains a cycle.
|
||||
"""
|
||||
graph = nx.DiGraph()
|
||||
graph: nx.DiGraph[str] = nx.DiGraph()
|
||||
target_names = set(config.targets)
|
||||
|
||||
for target_name, target_cfg in config.targets.items():
|
||||
|
|
@ -37,7 +37,7 @@ def build_graph(config: ProjectConfig, project_dir: Path) -> nx.DiGraph:
|
|||
f"which is neither a defined target nor an existing file"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
graph.add_edge(dep, target_name)
|
||||
_ = graph.add_edge(dep, target_name)
|
||||
|
||||
if not nx.is_directed_acyclic_graph(graph):
|
||||
cycles = list(nx.simple_cycles(graph))
|
||||
|
|
@ -47,7 +47,7 @@ def build_graph(config: ProjectConfig, project_dir: Path) -> nx.DiGraph:
|
|||
return graph
|
||||
|
||||
|
||||
def get_build_order(graph: nx.DiGraph) -> list[list[str]]:
|
||||
def get_build_order(graph: nx.DiGraph[str]) -> list[list[str]]:
|
||||
"""Return targets grouped into generations for parallel execution.
|
||||
|
||||
Each inner list contains nodes with no inter-dependencies that can
|
||||
|
|
@ -56,9 +56,9 @@ def get_build_order(graph: nx.DiGraph) -> list[list[str]]:
|
|||
return [list(gen) for gen in nx.topological_generations(graph)]
|
||||
|
||||
|
||||
def get_subgraph_for_target(graph: nx.DiGraph, target: str) -> nx.DiGraph:
|
||||
def get_subgraph_for_target(graph: nx.DiGraph[str], target: str) -> nx.DiGraph[str]:
|
||||
"""Return the subgraph containing *target* and all its transitive dependencies."""
|
||||
ancestors = nx.ancestors(graph, target)
|
||||
ancestors: set[str] = nx.ancestors(graph, target) # pyright: ignore[reportUnknownMemberType]
|
||||
ancestors.add(target)
|
||||
subgraph = nx.DiGraph(graph.subgraph(ancestors))
|
||||
subgraph: nx.DiGraph[str] = nx.DiGraph(graph.subgraph(ancestors))
|
||||
return subgraph
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue