eric5.UtilitiesPython2.py2flakes.checker

Global Attributes

_MAGIC_GLOBALS

Classes

Argument Represents binding a name as an argument.
Assignment Represents binding a name with an explicit assignment.
Binding Represents the binding of a value to a name.
Checker Class to check the cleanliness and sanity of Python code.
ClassScope Class representing a name scope for a class.
ExportBinding A binding created by an __all__ assignment.
FunctionDefinition Represents a function definition.
FunctionScope Class representing a name scope for a function.
Importation A binding created by an import statement.
ModuleScope Class representing a name scope for a module.
Scope Class defining the scope base class.
UnBinding Created by the 'del' operator.

Functions

iter_child_nodes Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes.


Argument

Represents binding a name as an argument.

Derived from

Binding

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


Assignment

Represents binding a name with an explicit assignment.

The checker will raise warnings for any Assignment that isn't used. Also, the checker does not consider assignments in tuple/list unpacking to be Assignments, rather it treats them as simple Bindings.

Derived from

Binding

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


Binding

Represents the binding of a value to a name.

The checker uses this to keep track of which names have been bound and which names have not. See L{Assignment} for a special type of binding that is checked with stricter rules.

Derived from

object

Class Attributes

None

Class Methods

None

Methods

Binding
__repr__
__str__

Static Methods

None

Binding (Constructor)

Binding(name, source)

Binding.__repr__

__repr__()

Binding.__str__

__str__()
Up


Checker

Class to check the cleanliness and sanity of Python code.

Derived from

object

Class Attributes

AND
BITOR
BOOLOP
CALL
COMPREHENSION
CONTINUE
EQ
GENERATOREXP
LOAD
NUM
RETURN
SLICE
nodeDepth
scope
traceTree

Class Methods

None

Methods

Checker Constructor
ASSIGN
AUGASSIGN
CLASSDEF Check names used in a class definition, including its decorators, base classes, and the body of its definition.
DICTCOMP
FOR Process bindings for loop variables.
FUNCTIONDEF
GLOBAL Keep track of globals declarations.
IMPORT
IMPORTFROM
LAMBDA
LISTCOMP
NAME Locate the name in locals / function / globals scopes.
_runDeferred Run the callables in deferred using their associated scope stack.
addArgs
addBinding Called when a binding is altered.
checkUnusedAssignments Check to see if any assignments have not been used.
check_dead_scopes Look at scopes which have been fully examined and report names in them which were imported but unused.
collectLoopVars
deferAssignment Schedule an assignment handler to be called just after deferred function handlers.
deferFunction Schedule a function handler to be called just before completion.
handleChildren
handleNode
ignore
isDocstring Determine if the given node is a docstring, as long as it is at the correct place in the node tree.
popScope
pushClassScope
pushFunctionScope
report
runFunction
scope

Static Methods

None

Checker (Constructor)

Checker(module, filename='(none)')

Constructor

module
parsed module tree or module source code
filename
name of the module file (string)

Checker.ASSIGN

ASSIGN(node)

Checker.AUGASSIGN

AUGASSIGN(node)

Checker.CLASSDEF

CLASSDEF(node)

Check names used in a class definition, including its decorators, base classes, and the body of its definition. Additionally, add its name to the current scope.

Checker.DICTCOMP

DICTCOMP(node)

Checker.FOR

FOR(node)

Process bindings for loop variables.

Checker.FUNCTIONDEF

FUNCTIONDEF(node)

Checker.GLOBAL

GLOBAL(node)

Keep track of globals declarations.

Checker.IMPORT

IMPORT(node)

Checker.IMPORTFROM

IMPORTFROM(node)

Checker.LAMBDA

LAMBDA(node)

Checker.LISTCOMP

LISTCOMP(node)

Checker.NAME

NAME(node)

Locate the name in locals / function / globals scopes.

Checker._runDeferred

_runDeferred(deferred)

Run the callables in deferred using their associated scope stack.

Checker.addArgs

addArgs()

Checker.addBinding

addBinding(lineno, value, reportRedef=True)

Called when a binding is altered.

lineno
line of the statement responsible for the change (integer)
value
the optional new value, a Binding instance, associated with the binding; if None, the binding is deleted if it exists
reportRedef
flag indicating if rebinding while unused will be reported (boolean)

Checker.checkUnusedAssignments

checkUnusedAssignments()

Check to see if any assignments have not been used.

Checker.check_dead_scopes

check_dead_scopes()

Look at scopes which have been fully examined and report names in them which were imported but unused.

Checker.collectLoopVars

collectLoopVars()

Checker.deferAssignment

deferAssignment(callable)

Schedule an assignment handler to be called just after deferred function handlers.

Checker.deferFunction

deferFunction(callable)

Schedule a function handler to be called just before completion.

This is used for handling function bodies, which must be deferred because code later in the file might modify the global scope. When `callable` is called, the scope at the time this is called will be restored, however it will contain any new bindings added to it.

Checker.handleChildren

handleChildren(tree)

Checker.handleNode

handleNode(node, parent)

Checker.ignore

ignore(node)

Checker.isDocstring

isDocstring(node)

Determine if the given node is a docstring, as long as it is at the correct place in the node tree.

Checker.popScope

popScope()

Checker.pushClassScope

pushClassScope()

Checker.pushFunctionScope

pushFunctionScope()

Checker.report

report(messageClass, *args, **kwargs)

Checker.runFunction

runFunction()

Checker.scope

scope()
Up


ClassScope

Class representing a name scope for a class.

Derived from

Scope

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


ExportBinding

A binding created by an __all__ assignment. If the names in the list can be determined statically, they will be treated as names for export and additional checking applied to them.

The only __all__ assignment that can be recognized is one which takes the value of a literal list containing literal strings. For example::

__all__ = ["foo", "bar"]

Names which are imported and not otherwise used but appear in the value of __all__ will not have an unused import warning reported for them.

Derived from

Binding

Class Attributes

None

Class Methods

None

Methods

names Return a list of the names referenced by this binding.

Static Methods

None

ExportBinding.names

names()

Return a list of the names referenced by this binding.

Up


FunctionDefinition

Represents a function definition.

Derived from

Binding

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


FunctionScope

Class representing a name scope for a function.

Derived from

Scope

Class Attributes

None

Class Methods

None

Methods

FunctionScope

Static Methods

None

FunctionScope (Constructor)

FunctionScope()
Up


Importation

A binding created by an import statement.

Derived from

Binding

Class Attributes

None

Class Methods

None

Methods

Importation

Static Methods

None

Importation (Constructor)

Importation(name, source)
Up


ModuleScope

Class representing a name scope for a module.

Derived from

Scope

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


Scope

Class defining the scope base class.

Derived from

dict

Class Attributes

importStarred

Class Methods

None

Methods

Scope
__repr__

Static Methods

None

Scope (Constructor)

Scope()

Scope.__repr__

__repr__()
Up


UnBinding

Created by the 'del' operator.

Derived from

Binding

Class Attributes

None

Class Methods

None

Methods

None

Static Methods

None
Up


iter_child_nodes

iter_child_nodes(node, astcls=_ast.AST)

Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes.

Up