Analyzer
An analyzer for the _run method of a component.
Includes the analyzer itself and the data models used to represent the analysis results.
References
NONE
ArgUsages
Bases: BaseModel
Model representing the different types of argument usage in a run.
Attributes:
Name | Type | Description |
---|---|---|
required |
list[str]
|
A list of argument names that are required. |
optional |
list[str]
|
A list of argument names that are optional. |
MethodSignature
Bases: BaseModel
Model representing the signature of a method.
Attributes:
Name | Type | Description |
---|---|---|
parameters |
dict[str, ParameterInfo]
|
A dictionary of parameter names to their information. |
is_async |
bool
|
Whether the method is asynchronous. |
ParameterInfo
Bases: BaseModel
Model representing information about a method parameter.
Attributes:
Name | Type | Description |
---|---|---|
kind |
ParameterKind
|
The kind of the parameter. |
default |
str
|
The default value of the parameter, if any. |
annotation |
str
|
The type annotation of the parameter, if any. |
ParameterKind
Bases: StrEnum
Enum representing the different kinds of parameters a method can have.
RunAnalyzer(cls)
Bases: NodeVisitor
AST NodeVisitor that analyzes a class to build a RunProfile.
The run analyzer visits the AST nodes of a class to analyze the _run method and build a RunProfile. It will look for the usage of the **kwargs parameter in method calls and subscript expressions. The traversal result is stored as a RunProfile object.
Attributes:
Name | Type | Description |
---|---|---|
cls |
type
|
The class to analyze. |
profile |
RunProfile
|
The profile of the run being analyzed. |
Initialize the RunAnalyzer with a class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls |
type
|
The class to analyze. |
required |
visit_Call(node)
Visit a Call node in the AST.
This node represents a function call in the source code. Here, we are looking for calls to methods that fully pass the kwargs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Call
|
The Call node to visit. |
required |
visit_Subscript(node)
Visit a Subscript node in the AST.
The Subscript node represents a subscripted value in the source code. Example: kwargs["key"]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node |
Subscript
|
The Subscript node to visit. |
required |
RunArgumentUsageType
Bases: StrEnum
Enum representing the different types of argument usage in a run.
RunProfile(**data)
Bases: BaseModel
Model representing the profile of a run.
Attributes:
Name | Type | Description |
---|---|---|
arg_usages |
ArgUsages
|
A dictionary mapping argument usage types to lists of argument names. |
full_pass_methods |
list[str]
|
A list of method names that fully pass the kwargs. |
method_signatures |
dict[str, MethodSignature]
|
A dictionary mapping method names to their signatures. |
Initialize the RunProfile with the given data.
This is to circumvent Pylint false positives due to the usage of Field(default_factory=...).