Visitor Module
- class cli_command_parser.conversion.visitor.ScriptVisitor(smart_loop_handling: bool = True, track_refs: Collection[TrackedRef] = ())[source]
Bases:
NodeVisitor- visit_FunctionDef
- visit_AsyncFunctionDef
- visit_Lambda
- visit_ClassDef
- visit_While
- track_refs_to(ref: TrackedRef)[source]
Register a reference that should be tracked.
- visit_Import(node: Import)[source]
Processes a
import some_moduleorimport some_module as other_namestatement.- Parameters:
node¶ – The AST object representing the import statement.
- visit_ImportFrom(node: ImportFrom)[source]
Processes a
from module import namesstatement. If the module name matches one from which members were registered to be tracked, then the imported names (and anyasaliases) are processed. Members with canonical names that match an item that was registered to be tracked are added to the current scope / variable namespace.Relative module imports are handled fuzzily - no attempt is made to determine the fully qualified module name for the source file or to resolve what the relative import’s fully qualified module name would be. This may result in incorrect items being tracked if the name matched a tracked name in the matched tracked module.
- resolve_ref(name: RefName, only_visitable: Literal[False] = False) VisitFunc | AstCallable | None[source]
- resolve_ref(name: RefName, only_visitable: Literal[True]) VisitFunc | None
Resolve the given reference to a tracked item in the current scope.
- visit_withitem(item: withitem)[source]
Visit a single
withitem/ context expression within awith ...:statement that may include one or more ``withitem``s / content expressions.
- visit_Assign(node: Assign)[source]
Visit an assignment statement where one or more variables (stored in
Assign.targets) are being assigned one or more values (stored inAssign.value).
- visit_Call(node: Call) AstCallable | _NoCallType[source]