Module

analysis.fragile_paths

Lint rule — suggest relative paths for same-folder includes.

Flags cross-template references whose target lives in the same folder as the caller. Those references will break on a folder rename even though nothing about the caller↔target relationship changed. Rewriting them as./<basename>makes the folder move zero-edit.

Only a same-folder match is reported. Parent-folder suggestions (../x) are ambiguous and would produce false positives for legitimate cross-cutting library references, so they are intentionally out of scope for this rule.

Classes

FragilePathIssue 7 ▼
A single fragile-path finding.

A single fragile-path finding.

Attributes

Name Type Description
lineno int —
col_offset int —
statement str —
target str —
suggestion str —
severity str —

Methods

code 0 str ▼
Stable analysis code for a fragile same-folder template path.
property
def code(self) -> str
Returns
str
_FragilePathVisitor 6 ▼
Collect cross-template references whose target is a sibling of the caller.

Collect cross-template references whose target is a sibling of the caller.

Methods

visit_Include 1 ▼
def visit_Include(self, node: Include) -> None
Parameters
Name Type Description
node —
visit_Extends 1 ▼
def visit_Extends(self, node: Extends) -> None
Parameters
Name Type Description
node —
visit_Embed 1 ▼
def visit_Embed(self, node: Embed) -> None
Parameters
Name Type Description
node —
visit_Import 1 ▼
def visit_Import(self, node: Import) -> None
Parameters
Name Type Description
node —
visit_FromImport 1 ▼
def visit_FromImport(self, node: FromImport) -> None
Parameters
Name Type Description
node —
Internal Methods 1 ▼
__init__ 1 ▼
def __init__(self, caller_name: str) -> None
Parameters
Name Type Description
caller_name —

Functions

check_fragile_paths 2 list[FragilePathIssue] ▼
Return all fragile-path issues in *ast* for a caller named *caller_name*.
def check_fragile_paths(ast: Template, caller_name: str) -> list[FragilePathIssue]
Parameters
Name Type Description
ast Template
caller_name str
Returns
list[FragilePathIssue]