On this page
Python linter using tree-sitter AST parsing to detect library boundary violations including forbidden imports and stdout/logging usage.
#rlsbl.lint.python_ast
#rlsbl.lint.python_ast
Python linter using tree-sitter AST parsing to detect library boundary violations including forbidden imports and stdout/logging usage.
#_node_line
def _node_line(node)Return 1-based line number for a tree-sitter node.
#_collect_all_imports
def _collect_all_imports(tree, filepath)Walk AST and collect all imported top-level module names.
Returns a set of (package_name, file_path, line_number) tuples.
#_check_forbidden_imports
def _check_forbidden_imports(tree, filepath, config)Walk AST for import_statement and import_from_statement nodes.
#child_by_field
def child_by_field(node, field_name)Find the module name in an import_from_statement.
tree-sitter-python represents 'from foo import bar' with the module as a dotted_name or relative_import child before the 'import' keyword.
#_check_stdout
def _check_stdout(tree, filepath, config)Detect print(), sys.stdout/stderr.write(), and logging.* calls.
#_check_entry_points
def _check_entry_points(project_path, config)Check pyproject.toml for CLI entry point declarations.
#PythonAstLinter
Python linter using tree-sitter AST analysis.
#lint
def lint(self, project_path: str, config: LanguageLintConfig) -> list[LintResult]#scan_imports
def scan_imports(self, project_path: str) -> set[tuple[str, str, int]]Collect all imported top-level module names from Python files.
Returns a set of (package_name, file_path, line_number) tuples.