class TypeChecker(BaseChecker): (source)
Try to find bugs in the code using type inference.
Method | open |
Called before visiting project (i.e. set of modules). |
Method | visit |
Process assignments in the AST. |
Method | visit |
Undocumented |
Method | visit |
Check that the accessed attribute exists. |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Check that called functions/methods are inferred to callable objects, and that passed arguments match the parameters in the inferred function. |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Undocumented |
Method | visit |
Detect TypeErrors for unary operands. |
Method | visit |
Undocumented |
Class Variable | name |
Name of the provider. |
Class Variable | options |
Options provided by this provider. |
Static Method | _is |
Undocumented |
Static Method | _is |
Undocumented |
Static Method | _keyword |
Check if the keyword argument exists in all signatures of the return values of all decorators of the function. |
Method | _check |
Match the supplied argument names against the function parameters. |
Method | _check |
When assigning to a function call, check that the function returns a valid value. |
Method | _check |
Undocumented |
Method | _check |
Undocumented |
Method | _check |
Check a string is assigned to self.__name__. |
Method | _check |
Undocumented |
Method | _check |
Undocumented |
Method | _check |
Undocumented |
Method | _check |
Undocumented |
Method | _check |
Checks to see if the not-callable message should be emitted. |
Method | _check |
Check that the given uninferable Call node does not call an actual function. |
Method | _check |
Check if left or right node is of type `type`. |
Method | _detect |
Detect if unsupported alternative Union syntax (PEP 604) was used. |
Method | _get |
Undocumented |
Method | _includes |
Check if a set of overloads of an operator includes one that can be relied upon for our configured Python version. |
Method | _recursive |
Undocumented |
Method | _visit |
Detect TypeErrors for augmented binary arithmetic operands. |
Method | _visit |
Detect TypeErrors for binary arithmetic operands. |
Instance Variable | _mixin |
Undocumented |
Instance Variable | _py310 |
Undocumented |
Property | _compiled |
Undocumented |
Property | _suggestion |
Undocumented |
Inherited from BaseChecker
:
Method | __eq__ |
Permit to assert Checkers are equal. |
Method | __gt__ |
Sorting of checkers. |
Method | __hash__ |
Make Checker hashable. |
Method | __init__ |
Checker instances should have the linter as argument. |
Method | __repr__ |
Undocumented |
Method | __str__ |
This might be incomplete because multiple classes inheriting BaseChecker can have the same name. |
Method | add |
Undocumented |
Method | check |
Check the consistency of msgid. |
Method | close |
Called after visiting project (i.e set of modules). |
Method | create |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | reduce |
Undocumented |
Class Variable | enabled |
Undocumented |
Class Variable | msgs |
Undocumented |
Class Variable | reports |
Undocumented |
Instance Variable | linter |
Undocumented |
Property | messages |
Undocumented |
Inherited from _ArgumentsProvider
(via BaseChecker
):
Method | get |
DEPRECATED: Return the dictionary defining an option given its name. |
Method | level |
Undocumented |
Method | load |
DEPRECATED: Initialize the provider using default values. |
Method | option |
DEPRECATED: Get the config attribute corresponding to opt. |
Method | option |
DEPRECATED: Get the current value for the given option. |
Method | options |
DEPRECATED. |
Method | options |
DEPRECATED: Return an iterator on options grouped by section. |
Method | set |
DEPRECATED: Method called to set an option (registered in the options list). |
Class Variable | option |
Option groups of this provider and their descriptions. |
Property | config |
Undocumented |
Property | level |
Undocumented |
Instance Variable | _arguments |
The manager that will parse and register any options provided. |
Instance Variable | _level |
Undocumented |
def visit_assign(self, node:
nodes.Assign
):
(source)
¶
Process assignments in the AST.
def visit_attribute(self, node:
(nodes.Attribute|nodes.AssignAttr)|nodes.DelAttr
):
(source)
¶
Check that the accessed attribute exists. to avoid too much false positives for now, we'll consider the code as correct if a single of the inferred nodes has the accessed attribute. function/method, super call and metaclasses are ignored
def visit_await(self, node:
nodes.Await
):
(source)
¶
Undocumented
def visit_binop(self, node:
nodes.BinOp
):
(source)
¶
Undocumented
Check that called functions/methods are inferred to callable objects, and that passed arguments match the parameters in the inferred function.
def visit_classdef(self, node:
nodes.ClassDef
):
(source)
¶
Undocumented
def visit_compare(self, node:
nodes.Compare
):
(source)
¶
Undocumented
def visit_for(self, node:
nodes.For
):
(source)
¶
Undocumented
def visit_functiondef(self, node:
nodes.FunctionDef
):
(source)
¶
Undocumented
def visit_subscript(self, node:
nodes.Subscript
):
(source)
¶
Undocumented
def visit_unaryop(self, node:
nodes.UnaryOp
):
(source)
¶
Detect TypeErrors for unary operands.
def visit_with(self, node:
nodes.With
):
(source)
¶
Undocumented
def _is_ignored_function(function_node:
nodes.FunctionDef|bases.UnboundMethod
) -> bool
:
(source)
¶
Undocumented
def _keyword_argument_is_in_all_decorator_returns(func:
nodes.FunctionDef
, keyword: str
) -> bool
:
(source)
¶
Check if the keyword argument exists in all signatures of the return values of all decorators of the function.
nodes.Call
, call_site: arguments.CallSite
, called: CallableObjects
, called_param_names: list[ str|None]
):
(source)
¶
Match the supplied argument names against the function parameters. Warn if some argument names are not in the same order as they are in the function signature.
Checks to see if the not-callable message should be emitted. Only functions, generators and objects defining __call__ are "callable" We ignore instances of descriptors since astroid cannot properly handle them yet
Check if left or right node is of type `type`. If either is, and doesn't support an or operator via a metaclass, infer that this is a mistaken attempt to use alternative union syntax when not supported.
(nodes.Attribute|nodes.AssignAttr)|nodes.DelAttr
, owner: SuccessfulInferenceResult
) -> tuple[ Literal[ 'c-extension-no-member', 'no-member'], str]
:
(source)
¶
Undocumented
Check if a set of overloads of an operator includes one that can be relied upon for our configured Python version. If we are running under a Python 3.10+ runtime but configured for pre-3.10 compatibility then Astroid will have inferred the existence of __or__ / __ror__ on builtins.type, but these aren't available in the configured version of Python.
nodes.ClassDef
, operation: Literal[ '__or__', '__ror__']
) -> bool|VERSION_COMPATIBLE_OVERLOAD
:
(source)
¶
Undocumented
def _visit_augassign(self, node:
nodes.AugAssign
):
(source)
¶
Detect TypeErrors for augmented binary arithmetic operands.
def _visit_binop(self, node:
nodes.BinOp
):
(source)
¶
Detect TypeErrors for binary arithmetic operands.