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

None


Argument

Represents binding a name as an argument.

Derived from

Binding

Class Attributes

None

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

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

Methods

Binding
__repr__
__str__

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

ASSLIST
AUGASSIGN
CONST
FLOORDIV
GENEXPRINNER
IFEXP
RETURN
RIGHTSHIFT
STMT
SUBSCRIPT
nodeDepth
scope
traceTree

Methods

Checker Constructor
ASSIGN
ASSNAME
CLASS Check names used in a class definition, including its decorators, base classes, and the body of its definition.
FOR Process bindings for loop variables.
FROM
FUNCTION
GLOBAL Keep track of globals declarations.
IMPORT
LAMBDA
LISTCOMP
NAME Locate the name in locals / function / globals scopes.
WITH Handle 'with' by checking the target of the statement (which can be an identifier, a list or tuple of targets, an attribute, etc) for undefined names and defining any it adds to the scope and by continuing to process the suite within the statement.
_runDeferred Run the callables in C{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
popScope
pushClassScope
pushFunctionScope
report
runFunction
scope

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.ASSNAME

ASSNAME(node)

Checker.CLASS

CLASS(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.FOR

FOR(node)

Process bindings for loop variables.

Checker.FROM

FROM(node)

Checker.FUNCTION

FUNCTION(node)

Checker.GLOBAL

GLOBAL(node)

Keep track of globals declarations.

Checker.IMPORT

IMPORT(node)

Checker.LAMBDA

LAMBDA(node)

Checker.LISTCOMP

LISTCOMP(node)

Checker.NAME

NAME(node)

Locate the name in locals / function / globals scopes.

Checker.WITH

WITH(node)

Handle 'with' by checking the target of the statement (which can be an identifier, a list or tuple of targets, an attribute, etc) for undefined names and defining any it adds to the scope and by continuing to process the suite within the statement.

Checker._runDeferred

_runDeferred(deferred)

Run the callables in C{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.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

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

Methods

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

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

Methods

None
Up


FunctionScope

Class representing a name scope for a function.

Derived from

Scope

Class Attributes

None

Methods

FunctionScope

FunctionScope (Constructor)

FunctionScope()
Up


Importation

A binding created by an import statement.

Derived from

Binding

Class Attributes

None

Methods

Importation

Importation (Constructor)

Importation(name, source)
Up


ModuleScope

Class representing a name scope for a module.

Derived from

Scope

Class Attributes

None

Methods

None
Up


Scope

Class defining the scope base class.

Derived from

dict

Class Attributes

importStarred

Methods

Scope
__repr__

Scope (Constructor)

Scope()

Scope.__repr__

__repr__()
Up


UnBinding

Created by the 'del' operator.

Derived from

Binding

Class Attributes

None

Methods

None
Up