class PatternChecker(PatternVisitor[
Pattern checker. This class checks if a pattern can match a type, what the type can be narrowed to, and what type capture patterns should be inferred as.
Method | __init__ |
Undocumented |
Method | accept |
Undocumented |
Method | can |
Undocumented |
Method | construct |
If outer_type is a child class of typing.Sequence returns a new instance of outer_type, that is a Sequence of inner_type. If outer_type is not a child class of typing.Sequence just returns a Sequence of inner_type... |
Method | contract |
Contracts a list of types in a sequence pattern depending on the position of a starred capture pattern. |
Method | early |
Undocumented |
Method | expand |
Undoes the contraction done by contract_starred_pattern_types. |
Method | generate |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | should |
Undocumented |
Method | update |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Class Variable | subject |
Undocumented |
Class Variable | subject |
Undocumented |
Instance Variable | chk |
Undocumented |
Instance Variable | msg |
Undocumented |
Instance Variable | non |
Undocumented |
Instance Variable | plugin |
Undocumented |
Instance Variable | self |
Undocumented |
Instance Variable | type |
Undocumented |
If outer_type is a child class of typing.Sequence returns a new instance of outer_type, that is a Sequence of inner_type. If outer_type is not a child class of typing.Sequence just returns a Sequence of inner_type For example: construct_sequence_child(List[int], str) = List[str] TODO: this doesn't make sense. For example if one has class S(Sequence[int], Generic[T]) or class T(Sequence[Tuple[T, T]]), there is no way any of those can map to Sequence[str].
list[ Type]
, star_pos: int|None
, num_patterns: int
) -> list[ Type]
:
(source)
¶
Contracts a list of types in a sequence pattern depending on the position of a starred capture pattern. For example if the sequence pattern [a, *b, c] is matched against types [bool, int, str, bytes] the contracted types are [bool, Union[int, str], bytes]. If star_pos in None the types are returned unchanged.
list[ Type]
, star_pos: int|None
, num_types: int
) -> list[ Type]
:
(source)
¶
Undoes the contraction done by contract_starred_pattern_types. For example if the sequence pattern is [a, *b, c] and types [bool, int, str] are extended to length 4 the result is [bool, int, int, str].
MappingPattern
, mapping_type: Type
, key: Expression
) -> Type|None
:
(source)
¶
Undocumented
MappingPattern
, mapping_type: Type
, key: Expression
) -> Type
:
(source)
¶
Undocumented
dict[ Expression, Type]
, extra_type_map: dict[ Expression, Type]
):
(source)
¶
Undocumented