module documentation

Shared definitions used by different parts of semantic analysis.

Class HasPlaceholders Undocumented
Class SemanticAnalyzerCoreInterface A core abstract interface to generic semantic analyzer functionality.
Class SemanticAnalyzerInterface A limited abstract interface to some generic semantic analyzer pass 2 functionality.
Function calculate_tuple_fallback Calculate a precise item type for the fallback of a tuple type.
Function find_dataclass_transform_spec Find the dataclass transform spec for the given node, if any exists.
Function has_placeholder Check if a type contains any placeholder types (recursively).
Function paramspec_args Undocumented
Function paramspec_kwargs Undocumented
Function require_bool_literal_argument Attempt to interpret an expression as a boolean literal, and fail analysis if we can't.
Function set_callable_name Undocumented
Constant ALLOW_INCOMPATIBLE_OVERRIDE Undocumented
Constant PRIORITY_FALLBACKS Undocumented
Class _NamedTypeCallback Undocumented
def calculate_tuple_fallback(typ: TupleType): (source)

Calculate a precise item type for the fallback of a tuple type. This must be called only after the main semantic analysis pass, since joins aren't available before that. Note that there is an apparent chicken and egg problem with respect to verifying type arguments against bounds. Verifying bounds might require fallbacks, but we might use the bounds to calculate the fallbacks. In practice this is not a problem, since the worst that can happen is that we have invalid type argument values, and these can happen in later stages as well (they will generate errors, but we don't prevent their existence).

def find_dataclass_transform_spec(node: Node|None) -> DataclassTransformSpec|None: (source)

Find the dataclass transform spec for the given node, if any exists. Per PEP 681 (https://peps.python.org/pep-0681/#the-dataclass-transform-decorator), dataclass transforms can be specified in multiple ways, including decorator functions and metaclasses/base classes. This function resolves the spec from any of these variants.

def has_placeholder(typ: Type) -> bool: (source)

Check if a type contains any placeholder types (recursively).

def paramspec_args(name: str, fullname: str, id: TypeVarId|int, *, named_type_func: _NamedTypeCallback, line: int = -1, column: int = -1, prefix: Parameters|None = None) -> ParamSpecType: (source)

Undocumented

def paramspec_kwargs(name: str, fullname: str, id: TypeVarId|int, *, named_type_func: _NamedTypeCallback, line: int = -1, column: int = -1, prefix: Parameters|None = None) -> ParamSpecType: (source)

Undocumented

@overload
def require_bool_literal_argument(api: SemanticAnalyzerInterface|SemanticAnalyzerPluginInterface, expression: Expression, name: str, default: Literal[True]|Literal[False]) -> bool:
@overload
def require_bool_literal_argument(api: SemanticAnalyzerInterface|SemanticAnalyzerPluginInterface, expression: Expression, name: str, default: None = None) -> bool|None:
(source)

Attempt to interpret an expression as a boolean literal, and fail analysis if we can't.

def set_callable_name(sig: Type, fdef: FuncDef) -> ProperType: (source)

Undocumented

ALLOW_INCOMPATIBLE_OVERRIDE: tuple[str, ...] = (source)

Undocumented

Value
('__slots__', '__deletable__', '__match_args__')
PRIORITY_FALLBACKS: int = (source)

Undocumented

Value
1