Skip to content

dependencies

Dependency tracking for hot reload system.

Classes:

Classes

DependencyTracker

Bases: ABC

Abstract base class for dependency tracking.

Methods:

Functions

get_dependencies abstractmethod
Python
get_dependencies(module_path: Path) -> set[str]

Get dependencies for a module.

get_dependents abstractmethod
Python
get_dependents(module_name: str) -> set[str]

Get modules that depend on the given module.

ClassDefinitionTracker

Python
ClassDefinitionTracker()

Tracks class definitions and their changes.

Initialize the class definition tracker.

Methods:

Functions

extract_class_signatures
Python
extract_class_signatures(file_path: Path) -> dict[str, str]

Extract class method signatures from a Python file.

Returns:

  • dict[str, str]

    Dictionary mapping class names to their method signatures.

has_class_changed
Python
has_class_changed(file_path: Path, class_name: str) -> bool

Check if a class definition has changed.

Returns:

  • bool

    True if the class has changed, False otherwise.

update_signatures
Python
update_signatures(file_path: Path) -> None

Update stored signatures for a file.

DependencyGraph

Python
DependencyGraph(max_depth: int = 10)

Bases: DependencyTracker

Tracks module dependencies using AST analysis.

Initialize the dependency graph.

Parameters:

  • max_depth (int, default: 10 ) –

    Maximum dependency depth to traverse, by default 10.

Methods:

Functions

get_dependencies
Python
get_dependencies(module_path: Path) -> set[str]

Get dependencies for a module using AST analysis.

Returns:

  • set[str]

    Set of module dependencies.

_extract_imports
Python
_extract_imports(file_path: Path) -> set[str]

Extract import statements from a Python file.

Returns:

  • set[str]

    Set of imported module names.

get_dependents
Python
get_dependents(module_name: str) -> set[str]

Get modules that depend on the given module.

Returns:

  • set[str]

    Set of dependent module names.

add_dependency
Python
add_dependency(dependent: str, dependency: str) -> None

Add a dependency relationship.

remove_module
Python
remove_module(module_name: str) -> None

Remove a module from the dependency graph.

get_reload_order
Python
get_reload_order(changed_modules: set[str]) -> list[str]

Get optimal reload order for changed modules.

Returns:

  • list[str]

    List of modules in optimal reload order.

clear_cache
Python
clear_cache() -> None

Clear the module cache.