Visitor Module

cli_command_parser.conversion.visitor.scoped(func)[source]
class cli_command_parser.conversion.visitor.ScopedVisit[source]

Bases: object

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_callable(module: str, name: str, cb: Callable)[source]
track_refs_to(ref: TrackedRef)[source]
get_tracked_refs() TrackedRefMap[source]
visit_Import(node: Import)[source]
visit_ImportFrom(node: ImportFrom)[source]

Processes a from module import names statement. If the module name matches one from which members were registered to be tracked, then the imported names (and any as aliases) 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.

visit_For(node: For)[source]
visit_AsyncFor(node: For)
resolve_ref(name: str | AST | Attribute | Name | expr)[source]
visit_withitem(item)[source]
visit_Assign(node: Assign)[source]
visit_Call(node: Call)[source]
class cli_command_parser.conversion.visitor.TrackedRef(name: str)[source]

Bases: object

module
name
cli_command_parser.conversion.visitor.imp_names(imp: Import | ImportFrom) Iterator[tuple[str, str]][source]