rlsbl v0.40.1 /rlsbl.import_scanners
On this page

Python and Dart import scanners for dependency-import validation.

#rlsbl.import_scanners

#rlsbl.import_scanners

Python and Dart import scanners for dependency-import validation.

Filters raw import data to workspace-relevant imports, handles language-specific edge cases, and distinguishes lib/ vs test/ contexts.

#ImportInfo

A single workspace-relevant import detected in a source file.

#_is_test_context

python
def _is_test_context(filepath: str, project_path: str) -> bool

Determine whether a file is in a test directory.

Checks if any path component between project_path and filepath is 'test' or 'tests'.

#PythonImportScanner

Scan Python source files for workspace-relevant imports.

Uses the AST-based scanner from the lint system, then post-processes to filter out stdlib, relative imports, and non-workspace packages.

#scan

python
def scan(self, project_path: str, workspace_names: set[str]) -> list[ImportInfo]

Scan project_path for Python imports matching workspace members.

Args:

  • project_path: absolute path to the project root.
  • workspace_names: set of workspace member package names

(as they appear in pyproject.toml, e.g. "my-lib").

Returns:

  • list of ImportInfo for imports that match workspace members.

#DartImportScanner

Scan Dart source files for workspace-relevant package imports.

Uses regex to extract package names from import/export statements. Checks for missing generated (.g.dart) files when build_runner is configured.

#scan

python
def scan(self, project_path: str, workspace_names: set[str]) -> list[ImportInfo]

Scan project_path for Dart imports matching workspace members.

Args:

  • project_path: absolute path to the project root.
  • workspace_names: set of workspace member package names

(as they appear in pubspec.yaml).

Returns:

  • list of ImportInfo for imports that match workspace members.

Raises:

  • RuntimeError: if build.yaml exists but no .g.dart files

are found in the project (missing code generation).

#_check_generated_files

python
def _check_generated_files(self, project_path: str) -> None

Raise RuntimeError if build_runner is configured but no .g.dart files exist.