class documentation

class TypingChecker(BaseChecker): (source)

View In Hierarchy

Find issue specifically related to type annotations.

Method __init__ Initialize checker instance.
Method leave_module After parsing of module is complete, add messages for 'consider-using-alias' check.
Method open Called before visiting project (i.e. set of modules).
Method visit_annassign Undocumented
Method visit_attribute Undocumented
Method visit_name Undocumented
Class Variable msgs Undocumented
Class Variable name Name of the provider.
Class Variable options Options provided by this provider.
Static Method _is_deprecated_union_annotation Undocumented
Static Method _is_optional_none_annotation Undocumented
Method _broken_callable_location Check if node would be a broken location for collections.abc.Callable.
Method _check_broken_callable Check for 'collections.abc.Callable' inside Optional and Union.
Method _check_broken_noreturn Check for 'NoReturn' inside compound types.
Method _check_for_alternative_union_syntax Check if alternative union syntax could be used.
Method _check_for_typing_alias Check if typing alias is deprecated or could be replaced.
Method _check_union_types Undocumented
Method _is_binop_union_annotation Undocumented
Method _msg_postponed_eval_hint Message hint if postponed evaluation isn't enabled.
Method _parse_binops_typehints Undocumented
Instance Variable _alias_name_collisions Undocumented
Instance Variable _consider_using_alias_msgs Undocumented
Instance Variable _deprecated_typing_alias_msgs Undocumented
Instance Variable _found_broken_callable_location Undocumented
Instance Variable _py310_plus Undocumented
Instance Variable _py37_plus Undocumented
Instance Variable _py39_plus Undocumented
Instance Variable _should_check_alternative_union_syntax The use of alternative union syntax (PEP 604) requires Python 3.10 or Python 3.7+ with postponed evaluation.
Instance Variable _should_check_callable Undocumented
Instance Variable _should_check_noreturn Undocumented
Instance Variable _should_check_typing_alias The use of type aliases (PEP 585) requires Python 3.9 or Python 3.7+ with postponed evaluation.

Inherited from BaseChecker:

Method __eq__ Permit to assert Checkers are equal.
Method __gt__ Sorting of checkers.
Method __hash__ Make Checker hashable.
Method __repr__ Undocumented
Method __str__ This might be incomplete because multiple classes inheriting BaseChecker can have the same name.
Method add_message Undocumented
Method check_consistency Check the consistency of msgid.
Method close Called after visiting project (i.e set of modules).
Method create_message_definition_from_tuple Undocumented
Method get_full_documentation Undocumented
Method get_map_data Undocumented
Method get_message_definition Undocumented
Method reduce_map_data Undocumented
Class Variable enabled Undocumented
Class Variable reports Undocumented
Instance Variable linter Undocumented
Property messages Undocumented

Inherited from _ArgumentsProvider (via BaseChecker):

Method get_option_def DEPRECATED: Return the dictionary defining an option given its name.
Method level.setter Undocumented
Method load_defaults DEPRECATED: Initialize the provider using default values.
Method option_attrname DEPRECATED: Get the config attribute corresponding to opt.
Method option_value DEPRECATED: Get the current value for the given option.
Method options_and_values DEPRECATED.
Method options_by_section DEPRECATED: Return an iterator on options grouped by section.
Method set_option DEPRECATED: Method called to set an option (registered in the options list).
Class Variable option_groups_descs Option groups of this provider and their descriptions.
Property config Undocumented
Property level Undocumented
Instance Variable _arguments_manager The manager that will parse and register any options provided.
Instance Variable _level Undocumented
def __init__(self, linter: PyLinter): (source)

Initialize checker instance.

@only_required_for_messages('consider-using-alias', 'deprecated-typing-alias')
def leave_module(self, node: nodes.Module): (source)

After parsing of module is complete, add messages for 'consider-using-alias' check. Make sure results are safe to recommend / collision free.

def open(self): (source)

Called before visiting project (i.e. set of modules).

@only_required_for_messages('redundant-typehint-argument')
def visit_annassign(self, node: nodes.AnnAssign): (source)

Undocumented

@only_required_for_messages('deprecated-typing-alias', 'consider-using-alias', 'consider-alternative-union-syntax', 'broken-noreturn', 'broken-collections-callable')
def visit_attribute(self, node: nodes.Attribute): (source)

Undocumented

@only_required_for_messages('deprecated-typing-alias', 'consider-using-alias', 'consider-alternative-union-syntax', 'broken-noreturn', 'broken-collections-callable')
def visit_name(self, node: nodes.Name): (source)

Undocumented

Name of the provider.

options: tuple[tuple, ...] = (source)

Options provided by this provider.

@staticmethod
def _is_deprecated_union_annotation(annotation: nodes.NodeNG, union_name: str) -> bool: (source)

Undocumented

@staticmethod
def _is_optional_none_annotation(annotation: nodes.Subscript) -> bool: (source)

Undocumented

def _broken_callable_location(self, node: nodes.Name|nodes.Attribute) -> bool: (source)

Check if node would be a broken location for collections.abc.Callable.

def _check_broken_callable(self, node: nodes.Name|nodes.Attribute): (source)

Check for 'collections.abc.Callable' inside Optional and Union.

def _check_broken_noreturn(self, node: nodes.Name|nodes.Attribute): (source)

Check for 'NoReturn' inside compound types.

def _check_for_alternative_union_syntax(self, node: nodes.Name|nodes.Attribute, name: str): (source)

Check if alternative union syntax could be used. Requires - Python 3.10 - OR: Python 3.7+ with postponed evaluation in a type annotation context

def _check_for_typing_alias(self, node: nodes.Name|nodes.Attribute): (source)

Check if typing alias is deprecated or could be replaced. Requires - Python 3.9 - OR: Python 3.7+ with postponed evaluation in a type annotation context For Python 3.7+: Only emit message if change doesn't create any name collisions, only ever used in a type annotation context, and can safely be replaced.

def _check_union_types(self, types: list[nodes.NodeNG], annotation: nodes.NodeNG): (source)

Undocumented

def _is_binop_union_annotation(self, annotation: nodes.NodeNG) -> bool: (source)

Undocumented

def _msg_postponed_eval_hint(self, node: nodes.NodeNG) -> str: (source)

Message hint if postponed evaluation isn't enabled.

def _parse_binops_typehints(self, binop_node: nodes.BinOp, typehints_list: list[nodes.NodeNG]|None = None) -> list[nodes.NodeNG]: (source)

Undocumented

_alias_name_collisions: set[str] = (source)

Undocumented

_consider_using_alias_msgs: list[DeprecatedTypingAliasMsg] = (source)

Undocumented

_deprecated_typing_alias_msgs: list[DeprecatedTypingAliasMsg] = (source)

Undocumented

_found_broken_callable_location: bool = (source)

Undocumented

_py310_plus = (source)

Undocumented

_py37_plus = (source)

Undocumented

_py39_plus = (source)

Undocumented

_should_check_alternative_union_syntax = (source)

The use of alternative union syntax (PEP 604) requires Python 3.10 or Python 3.7+ with postponed evaluation.

_should_check_callable = (source)

Undocumented

_should_check_noreturn = (source)

Undocumented

_should_check_typing_alias = (source)

The use of type aliases (PEP 585) requires Python 3.9 or Python 3.7+ with postponed evaluation.