summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Douard <david.douard@logilab.fr>2013-06-17 15:06:48 +0200
committerDavid Douard <david.douard@logilab.fr>2013-06-17 15:06:48 +0200
commit34e999fc8d56fdeadda39bb8f7122e203af7d869 (patch)
tree85c406f60ea59578241ac0959591720d07fa0fda
parentb4a281669859719bf13e01b81c6d979fcc0ea2d7 (diff)
downloadpylint-34e999fc8d56fdeadda39bb8f7122e203af7d869.tar.gz
astng has been renamed astroid
-rw-r--r--ChangeLog1
-rw-r--r--README6
-rw-r--r--README.Python32
-rw-r--r--__pkginfo__.py2
-rw-r--r--checkers/__init__.py4
-rw-r--r--checkers/base.py92
-rw-r--r--checkers/classes.py68
-rw-r--r--checkers/design_analysis.py6
-rw-r--r--checkers/exceptions.py38
-rw-r--r--checkers/format.py6
-rw-r--r--checkers/imports.py16
-rw-r--r--checkers/logging.py22
-rw-r--r--checkers/misc.py2
-rw-r--r--checkers/newstyle.py20
-rw-r--r--checkers/similar.py2
-rw-r--r--checkers/strings.py32
-rw-r--r--checkers/typecheck.py48
-rw-r--r--checkers/utils.py68
-rw-r--r--checkers/variables.py60
-rw-r--r--doc/contribute.rst6
-rw-r--r--doc/faq.rst4
-rw-r--r--doc/installation.rst4
-rw-r--r--examples/custom.py16
-rw-r--r--interfaces.py10
-rw-r--r--lint.py66
-rw-r--r--pyreverse/diadefslib.py22
-rw-r--r--pyreverse/diagrams.py18
-rw-r--r--pyreverse/main.py6
-rw-r--r--pyreverse/utils.py2
-rw-r--r--test/input/func_f0001.py2
-rw-r--r--test/input/func_noerror_factory_method.py2
-rw-r--r--test/input/func_noerror_nonregr.py2
-rw-r--r--test/input/func_noerror_socket_member.py2
-rw-r--r--test/input/func_undefined_var.py2
-rw-r--r--test/regrtest_data/decimal_inference.py2
-rw-r--r--test/regrtest_data/import_package_subpackage_module.py24
-rw-r--r--test/regrtest_data/pygtk_enum_crash.py4
-rw-r--r--test/unittest_lint.py6
-rw-r--r--test/unittest_pyreverse_diadefs.py18
-rw-r--r--test/unittest_pyreverse_writer.py2
-rw-r--r--test/utils.py8
-rw-r--r--utils.py18
42 files changed, 371 insertions, 370 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f59847..17b5635 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ ChangeLog for Pylint
====================
--
+ * astng has been renamed astroid
* bitbucket #6: put back documentation in source distribution
* fix spelling of max-branchs option, now max-branches
diff --git a/README b/README
index 582d586..2d8248e 100644
--- a/README
+++ b/README
@@ -21,10 +21,10 @@ or read the archives at http://lists.python.org/pipermail/code-quality/
Install
-------
-Pylint requires the astng (the later the better) and logilab-common (version >=
-0.53) packages.
+Pylint requires the astroid (the later the better; used to be called
+logilab-astng) and logilab-common (version >= 0.53) packages.
-* https://bitbucket.org/logilab/astng
+* https://bitbucket.org/logilab/astroid
* http://www.logilab.org/projects/common
From the source distribution, extract the tarball and run ::
diff --git a/README.Python3 b/README.Python3
index ccc9297..aee0f2b 100644
--- a/README.Python3
+++ b/README.Python3
@@ -20,7 +20,7 @@ build step when invoked by the python3 interpreter::
In order to run pylint locally, you have to install the dependencies::
easy_install-3.2 logilab-common
- easy_install-3.2 logilab-astng
+ easy_install-3.2 astroid
Debian
diff --git a/__pkginfo__.py b/__pkginfo__.py
index a018f93..3f5fd6e 100644
--- a/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -21,7 +21,7 @@ modname = distname = 'pylint'
numversion = (0, 28, 0)
version = '.'.join([str(num) for num in numversion])
-install_requires = ['logilab-common >= 0.53.0', 'logilab-astng >= 0.24.3']
+install_requires = ['logilab-common >= 0.53.0', 'logilab-astroid >= 0.24.3']
license = 'GPL'
description = "python code static checker"
diff --git a/checkers/__init__.py b/checkers/__init__.py
index dd868c6..cc95ea7 100644
--- a/checkers/__init__.py
+++ b/checkers/__init__.py
@@ -43,7 +43,7 @@ import warnings
from os import listdir
from os.path import dirname, join, isdir, splitext
-from logilab.astng.utils import ASTWalker
+from astroid.utils import ASTWalker
from logilab.common.modutils import load_module_from_file
from logilab.common.configuration import OptionsProviderMixIn
@@ -126,7 +126,7 @@ class BaseRawChecker(BaseChecker):
"use the ITokenChecker interface.",
DeprecationWarning)
stream = node.file_stream
- stream.seek(0) # XXX may be removed with astng > 0.23
+ stream.seek(0) # XXX may be removed with astroid > 0.23
self.process_tokens(tokenize.generate_tokens(stream.readline))
def process_tokens(self, tokens):
diff --git a/checkers/base.py b/checkers/base.py
index 92fc978..30ef434 100644
--- a/checkers/base.py
+++ b/checkers/base.py
@@ -16,11 +16,11 @@
"""basic checker for Python code"""
-from logilab import astng
+import astroid
from logilab.common.ureports import Table
-from logilab.astng import are_exclusive
+from astroid import are_exclusive
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.reporters import diff_string
from pylint.checkers import BaseChecker, EmptyReport
from pylint.checkers.utils import (
@@ -48,8 +48,8 @@ def in_loop(node):
"""return True if the node is inside a kind of for loop"""
parent = node.parent
while parent is not None:
- if isinstance(parent, (astng.For, astng.ListComp, astng.SetComp,
- astng.DictComp, astng.GenExpr)):
+ if isinstance(parent, (astroid.For, astroid.ListComp, astroid.SetComp,
+ astroid.DictComp, astroid.GenExpr)):
return True
parent = parent.parent
return False
@@ -68,13 +68,13 @@ def in_nested_list(nested_list, obj):
def _loop_exits_early(loop):
"""Returns true if a loop has a break statement in its body."""
- loop_nodes = (astng.For, astng.While)
+ loop_nodes = (astroid.For, astroid.While)
# Loop over body explicitly to avoid matching break statements
# in orelse.
for child in loop.body:
if isinstance(child, loop_nodes):
continue
- for _ in child.nodes_of_class(astng.Break, skip_klass=loop_nodes):
+ for _ in child.nodes_of_class(astroid.Break, skip_klass=loop_nodes):
return True
return False
@@ -130,13 +130,13 @@ def redefined_by_decorator(node):
"""
if node.decorators:
for decorator in node.decorators.nodes:
- if (isinstance(decorator, astng.Getattr) and
+ if (isinstance(decorator, astroid.Getattr) and
getattr(decorator.expr, 'name', None) == node.name):
return True
return False
class _BasicChecker(BaseChecker):
- __implements__ = IASTNGChecker
+ __implements__ = IAstroidChecker
name = 'basic'
class BasicErrorChecker(_BasicChecker):
@@ -196,21 +196,21 @@ class BasicErrorChecker(_BasicChecker):
if not redefined_by_decorator(node):
self._check_redefinition(node.is_method() and 'method' or 'function', node)
# checks for max returns, branch, return in __init__
- returns = node.nodes_of_class(astng.Return,
- skip_klass=(astng.Function, astng.Class))
+ returns = node.nodes_of_class(astroid.Return,
+ skip_klass=(astroid.Function, astroid.Class))
if node.is_method() and node.name == '__init__':
if node.is_generator():
self.add_message('E0100', node=node)
else:
values = [r.value for r in returns]
if [v for v in values if not (v is None or
- (isinstance(v, astng.Const) and v.value is None)
- or (isinstance(v, astng.Name) and v.name == 'None'))]:
+ (isinstance(v, astroid.Const) and v.value is None)
+ or (isinstance(v, astroid.Name) and v.name == 'None'))]:
self.add_message('E0101', node=node)
elif node.is_generator():
# make sure we don't mix non-None returns and yields
for retnode in returns:
- if isinstance(retnode.value, astng.Const) and \
+ if isinstance(retnode.value, astroid.Const) and \
retnode.value.value is not None:
self.add_message('E0106', node=node,
line=retnode.fromlineno)
@@ -224,12 +224,12 @@ class BasicErrorChecker(_BasicChecker):
@check_messages('E0104')
def visit_return(self, node):
- if not isinstance(node.frame(), astng.Function):
+ if not isinstance(node.frame(), astroid.Function):
self.add_message('E0104', node=node)
@check_messages('E0105')
def visit_yield(self, node):
- if not isinstance(node.frame(), (astng.Function, astng.Lambda)):
+ if not isinstance(node.frame(), (astroid.Function, astroid.Lambda)):
self.add_message('E0105', node=node)
@check_messages('E0103')
@@ -252,7 +252,7 @@ class BasicErrorChecker(_BasicChecker):
def visit_unaryop(self, node):
"""check use of the non-existent ++ adn -- operator operator"""
if ((node.op in '+-') and
- isinstance(node.operand, astng.UnaryOp) and
+ isinstance(node.operand, astroid.UnaryOp) and
(node.operand.op == node.op)):
self.add_message('E0107', node=node, args=node.op*2)
@@ -269,7 +269,7 @@ class BasicErrorChecker(_BasicChecker):
"""check that a node is inside a for or while loop"""
_node = node.parent
while _node:
- if isinstance(_node, (astng.For, astng.While)):
+ if isinstance(_node, (astroid.For, astroid.While)):
break
_node = _node.parent
else:
@@ -296,7 +296,7 @@ functions, methods
* uses of the global statement
"""
- __implements__ = IASTNGChecker
+ __implements__ = IAstroidChecker
name = 'basic'
msgs = {
@@ -411,7 +411,7 @@ functions, methods
def visit_discard(self, node):
"""check for various kind of statements without effect"""
expr = node.value
- if isinstance(expr, astng.Const) and isinstance(expr.value,
+ if isinstance(expr, astroid.Const) and isinstance(expr.value,
basestring):
# treat string statement in a separated message
self.add_message('W0105', node=node)
@@ -422,11 +422,11 @@ functions, methods
# * a yield (which are wrapped by a discard node in _ast XXX)
# warn W0106 if we have any underlying function call (we can't predict
# side effects), else W0104
- if (isinstance(expr, (astng.Yield, astng.CallFunc)) or
- (isinstance(node.parent, astng.TryExcept) and
+ if (isinstance(expr, (astroid.Yield, astroid.CallFunc)) or
+ (isinstance(node.parent, astroid.TryExcept) and
node.parent.body == [node])):
return
- if any(expr.nodes_of_class(astng.CallFunc)):
+ if any(expr.nodes_of_class(astroid.CallFunc)):
self.add_message('W0106', node=node, args=expr.as_string())
else:
self.add_message('W0104', node=node)
@@ -446,11 +446,11 @@ functions, methods
# of the lambda.
return
call = node.body
- if not isinstance(call, astng.CallFunc):
+ if not isinstance(call, astroid.CallFunc):
# The body of the lambda must be a function call expression
# for the lambda to be unnecessary.
return
- # XXX are lambda still different with astng >= 0.18 ?
+ # XXX are lambda still different with astroid >= 0.18 ?
# *args and **kwargs need to be treated specially, since they
# are structured differently between the lambda and the function
# call (in the lambda they appear in the args.args list and are
@@ -460,14 +460,14 @@ functions, methods
ordinary_args = list(node.args.args)
if node.args.kwarg:
if (not call.kwargs
- or not isinstance(call.kwargs, astng.Name)
+ or not isinstance(call.kwargs, astroid.Name)
or node.args.kwarg != call.kwargs.name):
return
elif call.kwargs:
return
if node.args.vararg:
if (not call.starargs
- or not isinstance(call.starargs, astng.Name)
+ or not isinstance(call.starargs, astroid.Name)
or node.args.vararg != call.starargs.name):
return
elif call.starargs:
@@ -477,7 +477,7 @@ functions, methods
if len(ordinary_args) != len(call.args):
return
for i in xrange(len(ordinary_args)):
- if not isinstance(call.args[i], astng.Name):
+ if not isinstance(call.args[i], astroid.Name):
return
if node.args.args[i].name != call.args[i].name:
return
@@ -492,13 +492,13 @@ functions, methods
for default in node.args.defaults:
try:
value = default.infer().next()
- except astng.InferenceError:
+ except astroid.InferenceError:
continue
- if (isinstance(value, astng.Instance) and
+ if (isinstance(value, astroid.Instance) and
value.qname() in ('__builtin__.set', '__builtin__.dict', '__builtin__.list')):
if value is default:
msg = default.as_string()
- elif type(value) is astng.Instance:
+ elif type(value) is astroid.Instance:
msg = '%s (%s)' % (default.as_string(), value.qname())
else:
msg = '%s (%s)' % (default.as_string(), value.as_string())
@@ -513,7 +513,7 @@ functions, methods
"""
self._check_unreachable(node)
# Is it inside final body of a try...finally bloc ?
- self._check_not_in_finally(node, 'return', (astng.Function,))
+ self._check_not_in_finally(node, 'return', (astroid.Function,))
@check_messages('W0101')
def visit_continue(self, node):
@@ -532,7 +532,7 @@ functions, methods
# 1 - Is it right sibling ?
self._check_unreachable(node)
# 2 - Is it inside final body of a try...finally bloc ?
- self._check_not_in_finally(node, 'break', (astng.For, astng.While,))
+ self._check_not_in_finally(node, 'break', (astroid.For, astroid.While,))
@check_messages('W0101')
def visit_raise(self, node):
@@ -551,7 +551,7 @@ functions, methods
"""visit a CallFunc node -> check if this is not a blacklisted builtin
call and check for * or ** use
"""
- if isinstance(node.func, astng.Name):
+ if isinstance(node.func, astroid.Name):
name = node.func.name
# ignore the name if it's not a builtin (i.e. not defined in the
# locals nor globals scope)
@@ -561,7 +561,7 @@ functions, methods
self.add_message('W0141', node=node, args=name)
if node.starargs or node.kwargs:
scope = node.scope()
- if isinstance(scope, astng.Function):
+ if isinstance(scope, astroid.Function):
toprocess = [(n, vn) for (n, vn) in ((node.starargs, scope.args.vararg),
(node.kwargs, scope.args.kwarg)) if n]
if toprocess:
@@ -575,7 +575,7 @@ functions, methods
@check_messages('W0199')
def visit_assert(self, node):
"""check the use of an assert statement on a tuple."""
- if node.fail is None and isinstance(node.test, astng.Tuple) and \
+ if node.fail is None and isinstance(node.test, astroid.Tuple) and \
len(node.test.elts) == 2:
self.add_message('W0199', node=node)
@@ -584,7 +584,7 @@ functions, methods
"""check duplicate key in dictionary"""
keys = set()
for k, _ in node.items:
- if isinstance(k, astng.Const):
+ if isinstance(k, astroid.Const):
key = k.value
if key in keys:
self.add_message('W0109', node=node, args=key)
@@ -738,14 +738,14 @@ class NameChecker(_BasicChecker):
"""check module level assigned names"""
frame = node.frame()
ass_type = node.ass_type()
- if isinstance(ass_type, (astng.Comprehension, astng.Comprehension)):
+ if isinstance(ass_type, (astroid.Comprehension, astroid.Comprehension)):
self._check_name('inlinevar', node.name, node)
- elif isinstance(frame, astng.Module):
- if isinstance(ass_type, astng.Assign) and not in_loop(ass_type):
+ elif isinstance(frame, astroid.Module):
+ if isinstance(ass_type, astroid.Assign) and not in_loop(ass_type):
self._check_name('const', node.name, node)
- elif isinstance(ass_type, astng.ExceptHandler):
+ elif isinstance(ass_type, astroid.ExceptHandler):
self._check_name('variable', node.name, node)
- elif isinstance(frame, astng.Function):
+ elif isinstance(frame, astroid.Function):
# global introduced variable aren't in the function locals
if node.name in frame:
self._check_name('variable', node.name, node)
@@ -753,7 +753,7 @@ class NameChecker(_BasicChecker):
def _recursive_check_names(self, args, node):
"""check names in a possibly recursive list <arg>"""
for arg in args:
- if isinstance(arg, astng.AssName):
+ if isinstance(arg, astroid.AssName):
self._check_name('argument', arg.name, node)
else:
self._recursive_check_names(arg.elts, node)
@@ -817,12 +817,12 @@ class DocStringChecker(_BasicChecker):
def visit_function(self, node):
if self.config.no_docstring_rgx.match(node.name) is None:
ftype = node.is_method() and 'method' or 'function'
- if isinstance(node.parent.frame(), astng.Class):
+ if isinstance(node.parent.frame(), astroid.Class):
overridden = False
# check if node is from a method overridden by its ancestor
for ancestor in node.parent.frame().ancestors():
if node.name in ancestor and \
- isinstance(ancestor[node.name], astng.Function):
+ isinstance(ancestor[node.name], astroid.Function):
overridden = True
break
if not overridden:
@@ -875,7 +875,7 @@ class LambdaForComprehensionChecker(_BasicChecker):
"""
if not node.args:
return
- if not isinstance(node.args[0], astng.Lambda):
+ if not isinstance(node.args[0], astroid.Lambda):
return
infered = safe_infer(node.func)
if (infered
diff --git a/checkers/classes.py b/checkers/classes.py
index f2c2913..98a2f27 100644
--- a/checkers/classes.py
+++ b/checkers/classes.py
@@ -17,10 +17,10 @@
"""
from __future__ import generators
-from logilab import astng
-from logilab.astng import YES, Instance, are_exclusive, AssAttr
+import astroid
+from astroid import YES, Instance, are_exclusive, AssAttr
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
from pylint.checkers.utils import (PYMETHODS, overrides_a_method,
check_messages, is_attr_private, is_attr_protected, node_frame_class)
@@ -156,7 +156,7 @@ class ClassChecker(BaseChecker):
* unreachable code
"""
- __implements__ = (IASTNGChecker,)
+ __implements__ = (IAstroidChecker,)
# configuration section name
name = 'classes'
@@ -222,7 +222,7 @@ a metaclass class method.'}
if node.type == 'class':
try:
node.local_attr('__init__')
- except astng.NotFoundError:
+ except astroid.NotFoundError:
self.add_message('W0232', args=node, node=node)
@check_messages('E0203', 'W0201')
@@ -241,7 +241,7 @@ a metaclass class method.'}
defining_methods = self.config.defining_attr_methods
for attr, nodes in cnode.instance_attrs.iteritems():
nodes = [n for n in nodes if not
- isinstance(n.statement(), (astng.Delete, astng.AugAssign))]
+ isinstance(n.statement(), (astroid.Delete, astroid.AugAssign))]
if not nodes:
continue # error detected by typechecking
attr_defined = False
@@ -264,7 +264,7 @@ a metaclass class method.'}
# check attribute is defined as a class attribute
try:
cnode.local_attr(attr)
- except astng.NotFoundError:
+ except astroid.NotFoundError:
self.add_message('W0201', args=attr, node=node)
def visit_function(self, node):
@@ -281,25 +281,25 @@ a metaclass class method.'}
return
# check signature if the method overloads inherited method
for overridden in klass.local_attr_ancestors(node.name):
- # get astng for the searched method
+ # get astroid for the searched method
try:
meth_node = overridden[node.name]
except KeyError:
# we have found the method but it's not in the local
# dictionary.
- # This may happen with astng build from living objects
+ # This may happen with astroid build from living objects
continue
- if not isinstance(meth_node, astng.Function):
+ if not isinstance(meth_node, astroid.Function):
continue
self._check_signature(node, meth_node, 'overridden')
break
if node.decorators:
for decorator in node.decorators.nodes:
- if isinstance(decorator, astng.Getattr) and \
+ if isinstance(decorator, astroid.Getattr) and \
decorator.attrname in ('getter', 'setter', 'deleter'):
# attribute affectation will call this method, not hiding it
return
- if isinstance(decorator, astng.Name) and decorator.name == 'property':
+ if isinstance(decorator, astroid.Name) and decorator.name == 'property':
# attribute affectation will either call a setter or raise
# an attribute error, anyway not hiding the function
return
@@ -308,7 +308,7 @@ a metaclass class method.'}
overridden = klass.instance_attr(node.name)[0] # XXX
args = (overridden.root().name, overridden.fromlineno)
self.add_message('E0202', args=args, node=node)
- except astng.NotFoundError:
+ except astroid.NotFoundError:
pass
def leave_function(self, node):
@@ -387,8 +387,8 @@ a metaclass class method.'}
return
# If the expression begins with a call to super, that's ok.
- if isinstance(node.expr, astng.CallFunc) and \
- isinstance(node.expr.func, astng.Name) and \
+ if isinstance(node.expr, astroid.CallFunc) and \
+ isinstance(node.expr.func, astroid.Name) and \
node.expr.func.name == 'super':
return
@@ -416,7 +416,7 @@ a metaclass class method.'}
node.local_attr(attr)
# yes, stop here
continue
- except astng.NotFoundError:
+ except astroid.NotFoundError:
pass
# is it an instance attribute of a parent class ?
try:
@@ -428,7 +428,7 @@ a metaclass class method.'}
# is it an instance attribute ?
try:
defstmts = node.instance_attr(attr)
- except astng.NotFoundError:
+ except astroid.NotFoundError:
pass
else:
if len(defstmts) == 1:
@@ -530,7 +530,7 @@ a metaclass class method.'}
e0221_hack = [False]
def iface_handler(obj):
"""filter interface objects, it should be classes"""
- if not isinstance(obj, astng.Class):
+ if not isinstance(obj, astroid.Class):
e0221_hack[0] = True
self.add_message('E0221', node=node,
args=(obj.as_string(),))
@@ -545,10 +545,10 @@ a metaclass class method.'}
# don't check method beginning with an underscore,
# usually belonging to the interface implementation
continue
- # get class method astng
+ # get class method astroid
try:
method = node_method(node, name)
- except astng.NotFoundError:
+ except astroid.NotFoundError:
self.add_message('E0222', args=(name, iface.name),
node=node)
continue
@@ -558,12 +558,12 @@ a metaclass class method.'}
# check signature
self._check_signature(method, imethod,
'%s interface' % iface.name)
- except astng.InferenceError:
+ except astroid.InferenceError:
if e0221_hack[0]:
return
implements = Instance(node).getattr('__implements__')[0]
assignment = implements.parent
- assert isinstance(assignment, astng.Assign)
+ assert isinstance(assignment, astroid.Assign)
# assignment.expr can be a Name or a Tuple or whatever.
# Use as_string() for the message
# FIXME: in case of multiple interfaces, find which one could not
@@ -580,14 +580,14 @@ a metaclass class method.'}
klass_node = node.parent.frame()
to_call = _ancestors_to_call(klass_node)
not_called_yet = dict(to_call)
- for stmt in node.nodes_of_class(astng.CallFunc):
+ for stmt in node.nodes_of_class(astroid.CallFunc):
expr = stmt.func
- if not isinstance(expr, astng.Getattr) \
+ if not isinstance(expr, astroid.Getattr) \
or expr.attrname != '__init__':
continue
# skip the test if using super
- if isinstance(expr.expr, astng.CallFunc) and \
- isinstance(expr.expr.func, astng.Name) and \
+ if isinstance(expr.expr, astroid.CallFunc) and \
+ isinstance(expr.expr.func, astroid.Name) and \
expr.expr.func.name == 'super':
return
try:
@@ -599,7 +599,7 @@ a metaclass class method.'}
except KeyError:
if klass not in to_call:
self.add_message('W0233', node=expr, args=klass.name)
- except astng.InferenceError:
+ except astroid.InferenceError:
continue
for klass, method in not_called_yet.iteritems():
if klass.name == 'object' or method.parent.name == 'object':
@@ -611,8 +611,8 @@ a metaclass class method.'}
class_type is in 'class', 'interface'
"""
- if not (isinstance(method1, astng.Function)
- and isinstance(refmethod, astng.Function)):
+ if not (isinstance(method1, astroid.Function)
+ and isinstance(refmethod, astroid.Function)):
self.add_message('F0202', args=(method1, refmethod), node=method1)
return
# don't care about functions with unknown argument (builtins)
@@ -632,7 +632,7 @@ a metaclass class method.'}
"""Check that attribute lookup name use first attribute variable name
(self for method, cls for classmethod and mcs for metaclass).
"""
- return self._first_attrs and isinstance(node.expr, astng.Name) and \
+ return self._first_attrs and isinstance(node.expr, astroid.Name) and \
node.expr.name == self._first_attrs[-1]
def _ancestors_to_call(klass_node, method='__init__'):
@@ -643,19 +643,19 @@ def _ancestors_to_call(klass_node, method='__init__'):
for base_node in klass_node.ancestors(recurs=False):
try:
to_call[base_node] = base_node.igetattr(method).next()
- except astng.InferenceError:
+ except astroid.InferenceError:
continue
return to_call
def node_method(node, method_name):
- """get astng for <method_name> on the given class node, ensuring it
+ """get astroid for <method_name> on the given class node, ensuring it
is a Function node
"""
for n in node.local_attr(method_name):
- if isinstance(n, astng.Function):
+ if isinstance(n, astroid.Function):
return n
- raise astng.NotFoundError(method_name)
+ raise astroid.NotFoundError(method_name)
def register(linter):
"""required method to auto register this checker """
diff --git a/checkers/design_analysis.py b/checkers/design_analysis.py
index 2fabfa6..2a6b308 100644
--- a/checkers/design_analysis.py
+++ b/checkers/design_analysis.py
@@ -15,9 +15,9 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""check for signs of poor design"""
-from logilab.astng import Function, If, InferenceError
+from astroid import Function, If, InferenceError
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
import re
@@ -134,7 +134,7 @@ class MisdesignChecker(BaseChecker):
* size, complexity of functions, methods
"""
- __implements__ = (IASTNGChecker,)
+ __implements__ = (IAstroidChecker,)
# configuration section name
name = 'design'
diff --git a/checkers/exceptions.py b/checkers/exceptions.py
index db0ebcc..b681c6d 100644
--- a/checkers/exceptions.py
+++ b/checkers/exceptions.py
@@ -18,12 +18,12 @@ import sys
from logilab.common.compat import builtins
BUILTINS_NAME = builtins.__name__
-from logilab import astng
-from logilab.astng import YES, Instance, unpack_infer
+import astroid
+from astroid import YES, Instance, unpack_infer
from pylint.checkers import BaseChecker
from pylint.checkers.utils import is_empty, is_raising
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
OVERGENERAL_EXCEPTIONS = ('Exception',)
@@ -85,7 +85,7 @@ class ExceptionsChecker(BaseChecker):
* type of raise argument : string, Exceptions, other values
"""
- __implements__ = IASTNGChecker
+ __implements__ = IAstroidChecker
name = 'exceptions'
msgs = MSGS
@@ -110,7 +110,7 @@ class ExceptionsChecker(BaseChecker):
else:
try:
value = unpack_infer(expr).next()
- except astng.InferenceError:
+ except astroid.InferenceError:
return
self._check_raise_value(node, value)
@@ -118,29 +118,29 @@ class ExceptionsChecker(BaseChecker):
"""check for bad values, string exception and class inheritance
"""
value_found = True
- if isinstance(expr, astng.Const):
+ if isinstance(expr, astroid.Const):
value = expr.value
if isinstance(value, str):
self.add_message('W0701', node=node)
else:
self.add_message('E0702', node=node,
args=value.__class__.__name__)
- elif (isinstance(expr, astng.Name) and \
+ elif (isinstance(expr, astroid.Name) and \
expr.name in ('None', 'True', 'False')) or \
- isinstance(expr, (astng.List, astng.Dict, astng.Tuple,
- astng.Module, astng.Function)):
+ isinstance(expr, (astroid.List, astroid.Dict, astroid.Tuple,
+ astroid.Module, astroid.Function)):
self.add_message('E0702', node=node, args=expr.name)
- elif ( (isinstance(expr, astng.Name) and expr.name == 'NotImplemented')
- or (isinstance(expr, astng.CallFunc) and
- isinstance(expr.func, astng.Name) and
+ elif ( (isinstance(expr, astroid.Name) and expr.name == 'NotImplemented')
+ or (isinstance(expr, astroid.CallFunc) and
+ isinstance(expr.func, astroid.Name) and
expr.func.name == 'NotImplemented') ):
self.add_message('E0711', node=node)
- elif isinstance(expr, astng.BinOp) and expr.op == '%':
+ elif isinstance(expr, astroid.BinOp) and expr.op == '%':
self.add_message('W0701', node=node)
- elif isinstance(expr, (Instance, astng.Class)):
+ elif isinstance(expr, (Instance, astroid.Class)):
if isinstance(expr, Instance):
expr = expr._proxied
- if (isinstance(expr, astng.Class) and
+ if (isinstance(expr, astroid.Class) and
not inherit_from_std_ex(expr) and
expr.root().name != BUILTINS_NAME):
if expr.newstyle:
@@ -171,19 +171,19 @@ class ExceptionsChecker(BaseChecker):
msg = 'empty except clause should always appear last'
self.add_message('E0701', node=node, args=msg)
- elif isinstance(handler.type, astng.BoolOp):
+ elif isinstance(handler.type, astroid.BoolOp):
self.add_message('W0711', node=handler, args=handler.type.op)
else:
try:
excs = list(unpack_infer(handler.type))
- except astng.InferenceError:
+ except astroid.InferenceError:
continue
for exc in excs:
# XXX skip other non class nodes
- if exc is YES or not isinstance(exc, astng.Class):
+ if exc is YES or not isinstance(exc, astroid.Class):
continue
exc_ancestors = [anc for anc in exc.ancestors()
- if isinstance(anc, astng.Class)]
+ if isinstance(anc, astroid.Class)]
for previous_exc in exceptions_classes:
if previous_exc in exc_ancestors:
msg = '%s is an ancestor class of %s' % (
diff --git a/checkers/format.py b/checkers/format.py
index ea8cf17..60cc44b 100644
--- a/checkers/format.py
+++ b/checkers/format.py
@@ -27,9 +27,9 @@ if not hasattr(tokenize, 'NL'):
raise ValueError("tokenize.NL doesn't exist -- tokenize module too old")
from logilab.common.textutils import pretty_match
-from logilab.astng import nodes
+from astroid import nodes
-from pylint.interfaces import ITokenChecker, IASTNGChecker
+from pylint.interfaces import ITokenChecker, IAstroidChecker
from pylint.checkers import BaseTokenChecker
from pylint.checkers.utils import check_messages
from pylint.utils import WarningScope
@@ -171,7 +171,7 @@ class FormatChecker(BaseTokenChecker):
* use of <> instead of !=
"""
- __implements__ = (ITokenChecker, IASTNGChecker)
+ __implements__ = (ITokenChecker, IAstroidChecker)
# configuration section name
name = 'format'
diff --git a/checkers/imports.py b/checkers/imports.py
index fe204b1..c289b86 100644
--- a/checkers/imports.py
+++ b/checkers/imports.py
@@ -19,10 +19,10 @@ from logilab.common.graph import get_cycles, DotBackend
from logilab.common.modutils import is_standard_module
from logilab.common.ureports import VerbatimText, Paragraph
-from logilab import astng
-from logilab.astng import are_exclusive
+import astroid
+from astroid import are_exclusive
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker, EmptyReport
@@ -38,11 +38,11 @@ def get_first_import(node, context, name, base, level):
continue
if first.scope() is node.scope() and first.fromlineno > node.fromlineno:
continue
- if isinstance(first, astng.Import):
+ if isinstance(first, astroid.Import):
if any(fullname == iname[0] for iname in first.names):
found = True
break
- elif isinstance(first, astng.From):
+ elif isinstance(first, astroid.From):
if level == first.level and any(
fullname == '%s.%s' % (first.modname, iname[0]) for iname in first.names):
found = True
@@ -157,7 +157,7 @@ class ImportsChecker(BaseChecker):
* uses of deprecated modules
"""
- __implements__ = IASTNGChecker
+ __implements__ = IAstroidChecker
name = 'imports'
msgs = MSGS
@@ -241,7 +241,7 @@ given file (report RP0402 must not be disabled)'}
prev = node.previous_sibling()
if prev:
# consecutive future statements are possible
- if not (isinstance(prev, astng.From)
+ if not (isinstance(prev, astroid.From)
and prev.modname == '__future__'):
self.add_message('W0410', node=node)
return
@@ -261,7 +261,7 @@ given file (report RP0402 must not be disabled)'}
def get_imported_module(self, modnode, importnode, modname):
try:
return importnode.do_import_module(modname)
- except astng.InferenceError, ex:
+ except astroid.InferenceError, ex:
if str(ex) != modname:
args = '%r (%s)' % (modname, ex)
else:
diff --git a/checkers/logging.py b/checkers/logging.py
index 5e36226..2cbdedc 100644
--- a/checkers/logging.py
+++ b/checkers/logging.py
@@ -14,7 +14,7 @@
"""checker for use of Python logging
"""
-from logilab import astng
+import astroid
from pylint import checkers
from pylint import interfaces
from pylint.checkers import utils
@@ -57,7 +57,7 @@ CHECKED_CONVENIENCE_FUNCTIONS = set([
class LoggingChecker(checkers.BaseChecker):
"""Checks use of the logging module."""
- __implements__ = interfaces.IASTNGChecker
+ __implements__ = interfaces.IAstroidChecker
name = 'logging'
msgs = MSGS
@@ -79,16 +79,16 @@ class LoggingChecker(checkers.BaseChecker):
def visit_callfunc(self, node):
"""Checks calls to (simple forms of) logging methods."""
- if (not isinstance(node.func, astng.Getattr)
- or not isinstance(node.func.expr, astng.Name)):
+ if (not isinstance(node.func, astroid.Getattr)
+ or not isinstance(node.func.expr, astroid.Name)):
return
try:
logger_class = [inferred for inferred in node.func.expr.infer() if (
- isinstance(inferred, astng.Instance)
+ isinstance(inferred, astroid.Instance)
and any(ancestor for ancestor in inferred._proxied.ancestors() if (
ancestor.name == 'Logger'
and ancestor.parent.name == 'logging')))]
- except astng.exceptions.InferenceError:
+ except astroid.exceptions.InferenceError:
return
if (node.func.expr.name != self._logging_name and not logger_class):
return
@@ -103,9 +103,9 @@ class LoggingChecker(checkers.BaseChecker):
# Either no args, star args, or double-star args. Beyond the
# scope of this checker.
return
- if isinstance(node.args[0], astng.BinOp) and node.args[0].op == '%':
+ if isinstance(node.args[0], astroid.BinOp) and node.args[0].op == '%':
self.add_message('W1201', node=node)
- elif isinstance(node.args[0], astng.Const):
+ elif isinstance(node.args[0], astroid.Const):
self._check_format_string(node, 0)
def _check_log_methods(self, node):
@@ -116,9 +116,9 @@ class LoggingChecker(checkers.BaseChecker):
# Either a malformed call, star args, or double-star args. Beyond
# the scope of this checker.
return
- if isinstance(node.args[1], astng.BinOp) and node.args[1].op == '%':
+ if isinstance(node.args[1], astroid.BinOp) and node.args[1].op == '%':
self.add_message('W1201', node=node)
- elif isinstance(node.args[1], astng.Const):
+ elif isinstance(node.args[1], astroid.Const):
self._check_format_string(node, 1)
def _check_format_string(self, node, format_arg):
@@ -171,7 +171,7 @@ class LoggingChecker(checkers.BaseChecker):
Returns:
Number of AST nodes that aren't keywords.
"""
- return sum(1 for arg in args if not isinstance(arg, astng.Keyword))
+ return sum(1 for arg in args if not isinstance(arg, astroid.Keyword))
def register(linter):
diff --git a/checkers/misc.py b/checkers/misc.py
index 18d7586..9ecdde9 100644
--- a/checkers/misc.py
+++ b/checkers/misc.py
@@ -56,7 +56,7 @@ separated by a comma.'
notes
"""
stream = node.file_stream
- stream.seek(0) # XXX may be removed with astng > 0.23
+ stream.seek(0) # XXX may be removed with astroid > 0.23
# warning notes in the code
notes = []
for note in self.config.notes:
diff --git a/checkers/newstyle.py b/checkers/newstyle.py
index edadad8..a2fca20 100644
--- a/checkers/newstyle.py
+++ b/checkers/newstyle.py
@@ -16,9 +16,9 @@
"""check for new / old style related problems
"""
-from logilab import astng
+import astroid
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
from pylint.checkers.utils import check_messages
@@ -48,7 +48,7 @@ class NewStyleConflictChecker(BaseChecker):
* "super" usage
"""
- __implements__ = (IASTNGChecker,)
+ __implements__ = (IAstroidChecker,)
# configuration section name
name = 'newstyle'
@@ -69,9 +69,9 @@ class NewStyleConflictChecker(BaseChecker):
def visit_callfunc(self, node):
"""check property usage"""
parent = node.parent.frame()
- if (isinstance(parent, astng.Class) and
+ if (isinstance(parent, astroid.Class) and
not parent.newstyle and
- isinstance(node.func, astng.Name)):
+ isinstance(node.func, astroid.Name)):
name = node.func.name
if name == 'property':
self.add_message('W1001', node=node)
@@ -83,14 +83,14 @@ class NewStyleConflictChecker(BaseChecker):
if not node.is_method():
return
klass = node.parent.frame()
- for stmt in node.nodes_of_class(astng.CallFunc):
+ for stmt in node.nodes_of_class(astroid.CallFunc):
expr = stmt.func
- if not isinstance(expr, astng.Getattr):
+ if not isinstance(expr, astroid.Getattr):
continue
call = expr.expr
# skip the test if using super
- if isinstance(call, astng.CallFunc) and \
- isinstance(call.func, astng.Name) and \
+ if isinstance(call, astroid.CallFunc) and \
+ isinstance(call.func, astroid.Name) and \
call.func.name == 'super':
if not klass.newstyle:
# super should not be used on an old style class
@@ -100,7 +100,7 @@ class NewStyleConflictChecker(BaseChecker):
try:
supcls = (call.args and call.args[0].infer().next()
or None)
- except astng.InferenceError:
+ except astroid.InferenceError:
continue
if klass is not supcls:
supcls = getattr(supcls, 'name', supcls)
diff --git a/checkers/similar.py b/checkers/similar.py
index 6c1b893..a0e3db3 100644
--- a/checkers/similar.py
+++ b/checkers/similar.py
@@ -38,7 +38,7 @@ class Similar:
def append_stream(self, streamid, stream):
"""append a file to search for similarities"""
- stream.seek(0) # XXX may be removed with astng > 0.23
+ stream.seek(0) # XXX may be removed with astroid > 0.23
self.linesets.append(LineSet(streamid,
stream.readlines(),
self.ignore_comments,
diff --git a/checkers/strings.py b/checkers/strings.py
index 52ff003..5bb187a 100644
--- a/checkers/strings.py
+++ b/checkers/strings.py
@@ -21,9 +21,9 @@
import sys
import tokenize
-from logilab import astng
+import astroid
-from pylint.interfaces import ITokenChecker, IASTNGChecker
+from pylint.interfaces import ITokenChecker, IAstroidChecker
from pylint.checkers import BaseChecker, BaseTokenChecker
from pylint.checkers import utils
@@ -72,16 +72,16 @@ MSGS = {
specifiers is given too many arguments"),
}
-OTHER_NODES = (astng.Const, astng.List, astng.Backquote,
- astng.Lambda, astng.Function,
- astng.ListComp, astng.SetComp, astng.GenExpr)
+OTHER_NODES = (astroid.Const, astroid.List, astroid.Backquote,
+ astroid.Lambda, astroid.Function,
+ astroid.ListComp, astroid.SetComp, astroid.GenExpr)
class StringFormatChecker(BaseChecker):
"""Checks string formatting operations to ensure that the format string
is valid and the arguments match the format string.
"""
- __implements__ = (IASTNGChecker,)
+ __implements__ = (IAstroidChecker,)
name = 'string'
msgs = MSGS
@@ -91,7 +91,7 @@ class StringFormatChecker(BaseChecker):
left = node.left
args = node.right
- if not (isinstance(left, astng.Const)
+ if not (isinstance(left, astroid.Const)
and isinstance(left.value, basestring)):
return
format_string = left.value
@@ -114,11 +114,11 @@ class StringFormatChecker(BaseChecker):
# Check that the RHS of the % operator is a mapping object
# that contains precisely the set of keys required by the
# format string.
- if isinstance(args, astng.Dict):
+ if isinstance(args, astroid.Dict):
keys = set()
unknown_keys = False
for k, _ in args.items:
- if isinstance(k, astng.Const):
+ if isinstance(k, astroid.Const):
key = k.value
if isinstance(key, basestring):
keys.add(key)
@@ -137,7 +137,7 @@ class StringFormatChecker(BaseChecker):
for key in keys:
if key not in required_keys:
self.add_message('W1301', node=node, args=key)
- elif isinstance(args, OTHER_NODES + (astng.Tuple,)):
+ elif isinstance(args, OTHER_NODES + (astroid.Tuple,)):
type_name = type(args).__name__
self.add_message('E1303', node=node, args=type_name)
# else:
@@ -149,9 +149,9 @@ class StringFormatChecker(BaseChecker):
# Check that the number of arguments passed to the RHS of
# the % operator matches the number required by the format
# string.
- if isinstance(args, astng.Tuple):
+ if isinstance(args, astroid.Tuple):
num_args = len(args.elts)
- elif isinstance(args, OTHER_NODES + (astng.Dict, astng.DictComp)):
+ elif isinstance(args, OTHER_NODES + (astroid.Dict, astroid.DictComp)):
num_args = 1
else:
# The RHS of the format specifier is a name or
@@ -166,7 +166,7 @@ class StringFormatChecker(BaseChecker):
class StringMethodsChecker(BaseChecker):
- __implements__ = (IASTNGChecker,)
+ __implements__ = (IAstroidChecker,)
name = 'string'
msgs = {
'E1310': ("Suspicious argument in %s.%s call",
@@ -177,13 +177,13 @@ class StringMethodsChecker(BaseChecker):
def visit_callfunc(self, node):
func = utils.safe_infer(node.func)
- if (isinstance(func, astng.BoundMethod)
- and isinstance(func.bound, astng.Instance)
+ if (isinstance(func, astroid.BoundMethod)
+ and isinstance(func.bound, astroid.Instance)
and func.bound.name in ('str', 'unicode', 'bytes')
and func.name in ('strip', 'lstrip', 'rstrip')
and node.args):
arg = utils.safe_infer(node.args[0])
- if not isinstance(arg, astng.Const):
+ if not isinstance(arg, astroid.Const):
return
if len(arg.value) != len(set(arg.value)):
self.add_message('E1310', node=node,
diff --git a/checkers/typecheck.py b/checkers/typecheck.py
index 3dcac24..fba00d4 100644
--- a/checkers/typecheck.py
+++ b/checkers/typecheck.py
@@ -13,16 +13,16 @@
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-"""try to find more bugs in the code using astng inference capabilities
+"""try to find more bugs in the code using astroid inference capabilities
"""
import re
import shlex
-from logilab import astng
-from logilab.astng import InferenceError, NotFoundError, YES, Instance
+import astroid
+from astroid import InferenceError, NotFoundError, YES, Instance
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
from pylint.checkers.utils import safe_infer, is_super, check_messages
@@ -37,7 +37,7 @@ MSGS = {
'E1103': ('%s %r has no %r member (but some types could not be inferred)',
'maybe-no-member',
'Used when a variable is accessed for an unexistent member, but \
- astng was not able to interpret all possible types of this \
+ astroid was not able to interpret all possible types of this \
variable.'),
'E1111': ('Assigning to function call which doesn\'t return',
'assignment-from-no-return',
@@ -74,7 +74,7 @@ class TypeChecker(BaseChecker):
"""try to find bugs in the code using type inference
"""
- __implements__ = (IASTNGChecker,)
+ __implements__ = (IAstroidChecker,)
# configuration section name
name = 'typecheck'
@@ -120,7 +120,7 @@ accessed. Python regular expressions are accepted.'}
self.generated_members.extend(('REQUEST', 'acl_users', 'aq_parent'))
def visit_assattr(self, node):
- if isinstance(node.ass_type(), astng.AugAssign):
+ if isinstance(node.ass_type(), astroid.AugAssign):
self.visit_getattr(node)
def visit_delattr(self, node):
@@ -162,7 +162,7 @@ accessed. Python regular expressions are accepted.'}
inference_failure = True
continue
# skip None anyway
- if isinstance(owner, astng.Const) and owner.value is None:
+ if isinstance(owner, astroid.Const) and owner.value is None:
continue
# XXX "super" / metaclass call
if is_super(owner) or getattr(owner, 'type', None) == 'metaclass':
@@ -174,14 +174,14 @@ accessed. Python regular expressions are accepted.'}
continue
try:
if not [n for n in owner.getattr(node.attrname)
- if not isinstance(n.statement(), astng.AugAssign)]:
+ if not isinstance(n.statement(), astroid.AugAssign)]:
missingattr.add((owner, name))
continue
except AttributeError:
# XXX method / function
continue
except NotFoundError:
- if isinstance(owner, astng.Function) and owner.decorators:
+ if isinstance(owner, astroid.Function) and owner.decorators:
continue
if isinstance(owner, Instance) and owner.has_dynamic_getattr():
continue
@@ -217,23 +217,23 @@ accessed. Python regular expressions are accepted.'}
"""check that if assigning to a function call, the function is
possibly returning something valuable
"""
- if not isinstance(node.value, astng.CallFunc):
+ if not isinstance(node.value, astroid.CallFunc):
return
function_node = safe_infer(node.value.func)
# skip class, generator and incomplete function definition
- if not (isinstance(function_node, astng.Function) and
+ if not (isinstance(function_node, astroid.Function) and
function_node.root().fully_defined()):
return
if function_node.is_generator() \
or function_node.is_abstract(pass_is_abstract=False):
return
- returns = list(function_node.nodes_of_class(astng.Return,
- skip_klass=astng.Function))
+ returns = list(function_node.nodes_of_class(astroid.Return,
+ skip_klass=astroid.Function))
if len(returns) == 0:
self.add_message('E1111', node=node)
else:
for rnode in returns:
- if not (isinstance(rnode.value, astng.Const)
+ if not (isinstance(rnode.value, astroid.Const)
and rnode.value.value is None):
break
else:
@@ -250,7 +250,7 @@ accessed. Python regular expressions are accepted.'}
keyword_args = set()
num_positional_args = 0
for arg in node.args:
- if isinstance(arg, astng.Keyword):
+ if isinstance(arg, astroid.Keyword):
keyword = arg.arg
if keyword in keyword_args:
self.add_message('E1122', node=node, args=keyword)
@@ -265,18 +265,18 @@ accessed. Python regular expressions are accepted.'}
# Note that BoundMethod is a subclass of UnboundMethod (huh?), so must
# come first in this 'if..else'.
- if isinstance(called, astng.BoundMethod):
+ if isinstance(called, astroid.BoundMethod):
# Bound methods have an extra implicit 'self' argument.
num_positional_args += 1
- elif isinstance(called, astng.UnboundMethod):
+ elif isinstance(called, astroid.UnboundMethod):
if called.decorators is not None:
for d in called.decorators.nodes:
- if isinstance(d, astng.Name) and (d.name == 'classmethod'):
+ if isinstance(d, astroid.Name) and (d.name == 'classmethod'):
# Class methods have an extra implicit 'cls' argument.
num_positional_args += 1
break
- elif (isinstance(called, astng.Function) or
- isinstance(called, astng.Lambda)):
+ elif (isinstance(called, astroid.Function) or
+ isinstance(called, astroid.Lambda)):
pass
else:
return
@@ -295,15 +295,15 @@ accessed. Python regular expressions are accepted.'}
parameters = []
parameter_name_to_index = {}
for i, arg in enumerate(called.args.args):
- if isinstance(arg, astng.Tuple):
+ if isinstance(arg, astroid.Tuple):
name = None
# Don't store any parameter names within the tuple, since those
# are not assignable from keyword arguments.
else:
- if isinstance(arg, astng.Keyword):
+ if isinstance(arg, astroid.Keyword):
name = arg.arg
else:
- assert isinstance(arg, astng.AssName)
+ assert isinstance(arg, astroid.AssName)
# This occurs with:
# def f( (a), (b) ): pass
name = arg.name
diff --git a/checkers/utils.py b/checkers/utils.py
index da09e86..022c707 100644
--- a/checkers/utils.py
+++ b/checkers/utils.py
@@ -21,19 +21,19 @@
import re
import string
-from logilab import astng
-from logilab.astng import scoped_nodes
+import astroid
+from astroid import scoped_nodes
from logilab.common.compat import builtins
BUILTINS_NAME = builtins.__name__
-COMP_NODE_TYPES = astng.ListComp, astng.SetComp, astng.DictComp, astng.GenExpr
+COMP_NODE_TYPES = astroid.ListComp, astroid.SetComp, astroid.DictComp, astroid.GenExpr
def is_inside_except(node):
"""Returns true if node is inside the name of an except handler."""
current = node
- while current and not isinstance(current.parent, astng.ExceptHandler):
+ while current and not isinstance(current.parent, astroid.ExceptHandler):
current = current.parent
return current and current is current.parent.name
@@ -41,7 +41,7 @@ def is_inside_except(node):
def get_all_elements(node):
"""Recursively returns all atoms in nested lists and tuples."""
- if isinstance(node, (astng.Tuple, astng.List)):
+ if isinstance(node, (astroid.Tuple, astroid.List)):
for child in node.elts:
for e in get_all_elements(child):
yield e
@@ -56,9 +56,9 @@ def clobber_in_except(node):
Returns (True, args for W0623) if assignment clobbers an existing variable,
(False, None) otherwise.
"""
- if isinstance(node, astng.AssAttr):
+ if isinstance(node, astroid.AssAttr):
return (True, (node.attrname, 'object %r' % (node.expr.name,)))
- elif isinstance(node, astng.AssName):
+ elif isinstance(node, astroid.AssName):
name = node.name
if is_builtin(name):
return (True, (name, 'builtins'))
@@ -66,7 +66,7 @@ def clobber_in_except(node):
scope, stmts = node.lookup(name)
if (stmts and
not isinstance(stmts[0].ass_type(),
- (astng.Assign, astng.AugAssign, astng.ExceptHandler))):
+ (astroid.Assign, astroid.AugAssign, astroid.ExceptHandler))):
return (True, (name, 'outer scope (line %s)' % (stmts[0].fromlineno,)))
return (False, None)
@@ -79,12 +79,12 @@ def safe_infer(node):
try:
inferit = node.infer()
value = inferit.next()
- except astng.InferenceError:
+ except astroid.InferenceError:
return
try:
inferit.next()
return # None if there is ambiguity on the inferred node
- except astng.InferenceError:
+ except astroid.InferenceError:
return # there is some kind of ambiguity
except StopIteration:
return value
@@ -100,20 +100,20 @@ def is_super(node):
def is_error(node):
"""return true if the function does nothing but raising an exception"""
for child_node in node.get_children():
- if isinstance(child_node, astng.Raise):
+ if isinstance(child_node, astroid.Raise):
return True
return False
def is_raising(body):
"""return true if the given statement node raise an exception"""
for node in body:
- if isinstance(node, astng.Raise):
+ if isinstance(node, astroid.Raise):
return True
return False
def is_empty(body):
"""return true if the given node does nothing but 'pass'"""
- return len(body) == 1 and isinstance(body[0], astng.Pass)
+ return len(body) == 1 and isinstance(body[0], astroid.Pass)
builtins = builtins.__dict__.copy()
SPECIAL_BUILTINS = ('__builtins__',) # '__path__', '__file__')
@@ -136,20 +136,20 @@ def is_defined_before(var_node):
_node = var_node.parent
while _node:
if isinstance(_node, COMP_NODE_TYPES):
- for ass_node in _node.nodes_of_class(astng.AssName):
+ for ass_node in _node.nodes_of_class(astroid.AssName):
if ass_node.name == varname:
return True
- elif isinstance(_node, astng.For):
- for ass_node in _node.target.nodes_of_class(astng.AssName):
+ elif isinstance(_node, astroid.For):
+ for ass_node in _node.target.nodes_of_class(astroid.AssName):
if ass_node.name == varname:
return True
- elif isinstance(_node, astng.With):
+ elif isinstance(_node, astroid.With):
if _node.vars is None:
# quickfix : case in which 'with' is used without 'as'
return False
if _node.vars.name == varname:
return True
- elif isinstance(_node, (astng.Lambda, astng.Function)):
+ elif isinstance(_node, (astroid.Lambda, astroid.Function)):
if _node.args.is_argument(varname):
return True
if getattr(_node, 'name', None) == varname:
@@ -161,10 +161,10 @@ def is_defined_before(var_node):
_node = stmt.previous_sibling()
lineno = stmt.fromlineno
while _node and _node.fromlineno == lineno:
- for ass_node in _node.nodes_of_class(astng.AssName):
+ for ass_node in _node.nodes_of_class(astroid.AssName):
if ass_node.name == varname:
return True
- for imp_node in _node.nodes_of_class( (astng.From, astng.Import)):
+ for imp_node in _node.nodes_of_class( (astroid.From, astroid.Import)):
if varname in [name[1] or name[0] for name in imp_node.names]:
return True
_node = _node.previous_sibling()
@@ -175,9 +175,9 @@ def is_func_default(node):
value
"""
parent = node.scope()
- if isinstance(parent, astng.Function):
+ if isinstance(parent, astroid.Function):
for default_node in parent.args.defaults:
- for default_name_node in default_node.nodes_of_class(astng.Name):
+ for default_name_node in default_node.nodes_of_class(astroid.Name):
if default_name_node is node:
return True
return False
@@ -186,10 +186,10 @@ def is_func_decorator(node):
"""return true if the name is used in function decorator"""
parent = node.parent
while parent is not None:
- if isinstance(parent, astng.Decorators):
+ if isinstance(parent, astroid.Decorators):
return True
if (parent.is_statement or
- isinstance(parent, astng.Lambda) or
+ isinstance(parent, astroid.Lambda) or
isinstance(parent, (scoped_nodes.ComprehensionScope,
scoped_nodes.ListComp))):
break
@@ -197,7 +197,7 @@ def is_func_decorator(node):
return False
def is_ancestor_name(frame, node):
- """return True if `frame` is a astng.Class node with `node` in the
+ """return True if `frame` is a astroid.Class node with `node` in the
subtree of its bases attribute
"""
try:
@@ -205,23 +205,23 @@ def is_ancestor_name(frame, node):
except AttributeError:
return False
for base in bases:
- if node in base.nodes_of_class(astng.Name):
+ if node in base.nodes_of_class(astroid.Name):
return True
return False
def assign_parent(node):
"""return the higher parent which is not an AssName, Tuple or List node
"""
- while node and isinstance(node, (astng.AssName,
- astng.Tuple,
- astng.List)):
+ while node and isinstance(node, (astroid.AssName,
+ astroid.Tuple,
+ astroid.List)):
node = node.parent
return node
def overrides_an_abstract_method(class_node, name):
"""return True if pnode is a parent of node"""
for ancestor in class_node.ancestors():
- if name in ancestor and isinstance(ancestor[name], astng.Function) and \
+ if name in ancestor and isinstance(ancestor[name], astroid.Function) and \
ancestor[name].is_abstract(pass_is_abstract=False):
return True
return False
@@ -229,7 +229,7 @@ def overrides_an_abstract_method(class_node, name):
def overrides_a_method(class_node, name):
"""return True if <name> is a method overridden from an ancestor"""
for ancestor in class_node.ancestors():
- if name in ancestor and isinstance(ancestor[name], astng.Function):
+ if name in ancestor and isinstance(ancestor[name], astroid.Function):
return True
return False
@@ -352,7 +352,7 @@ def node_frame_class(node):
"""
klass = node.frame()
- while klass is not None and not isinstance(klass, astng.Class):
+ while klass is not None and not isinstance(klass, astroid.Class):
if klass.parent is None:
klass = None
else:
@@ -364,8 +364,8 @@ def is_super_call(expr):
"""return True if expression node is a function call and if function name
is super. Check before that you're in a method.
"""
- return (isinstance(expr, astng.CallFunc) and
- isinstance(expr.func, astng.Name) and
+ return (isinstance(expr, astroid.CallFunc) and
+ isinstance(expr.func, astroid.Name) and
expr.func.name == 'super')
def is_attr_private(attrname):
diff --git a/checkers/variables.py b/checkers/variables.py
index ff9a1d9..7f012f7 100644
--- a/checkers/variables.py
+++ b/checkers/variables.py
@@ -19,10 +19,10 @@
import sys
from copy import copy
-from logilab import astng
-from logilab.astng import are_exclusive, builtin_lookup, ASTNGBuildingException
+import astroid
+from astroid import are_exclusive, builtin_lookup, AstroidBuildingException
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
from pylint.checkers.utils import (PYMETHODS, is_ancestor_name, is_builtin,
is_defined_before, is_error, is_func_default, is_func_decorator,
@@ -32,7 +32,7 @@ from pylint.checkers.utils import (PYMETHODS, is_ancestor_name, is_builtin,
def in_for_else_branch(parent, stmt):
"""Returns True if stmt in inside the else branch for a parent For stmt."""
- return (isinstance(parent, astng.For) and
+ return (isinstance(parent, astroid.For) and
any(else_stmt.parent_of(stmt) for else_stmt in parent.orelse))
def overridden_method(klass, name):
@@ -45,9 +45,9 @@ def overridden_method(klass, name):
meth_node = parent[name]
except KeyError:
# We have found an ancestor defining <name> but it's not in the local
- # dictionary. This may happen with astng built from living objects.
+ # dictionary. This may happen with astroid built from living objects.
return None
- if isinstance(meth_node, astng.Function):
+ if isinstance(meth_node, astroid.Function):
return meth_node
return None
@@ -129,7 +129,7 @@ class VariablesChecker(BaseChecker):
* __all__ consistency
"""
- __implements__ = IASTNGChecker
+ __implements__ = IAstroidChecker
name = 'variables'
msgs = MSGS
@@ -175,14 +175,14 @@ builtins. Remember that you should avoid to define new builtins when possible.'
# attempt to check for __all__ if defined
if '__all__' in node.locals:
assigned = node.igetattr('__all__').next()
- if assigned is not astng.YES:
+ if assigned is not astroid.YES:
for elt in getattr(assigned, 'elts', ()):
try:
elt_name = elt.infer().next()
- except astng.InferenceError:
+ except astroid.InferenceError:
continue
- if not isinstance(elt_name, astng.Const) or not isinstance(elt_name.value, basestring):
+ if not isinstance(elt_name, astroid.Const) or not isinstance(elt_name.value, basestring):
self.add_message('E0604', args=elt.as_string(), node=elt)
continue
elt_name = elt.value
@@ -197,9 +197,9 @@ builtins. Remember that you should avoid to define new builtins when possible.'
return
for name, stmts in not_consumed.iteritems():
stmt = stmts[0]
- if isinstance(stmt, astng.Import):
+ if isinstance(stmt, astroid.Import):
self.add_message('W0611', args=name, node=stmt)
- elif isinstance(stmt, astng.From) and stmt.modname != '__future__':
+ elif isinstance(stmt, astroid.From) and stmt.modname != '__future__':
if stmt.names[0][0] == '*':
self.add_message('W0614', args=name, node=stmt)
else:
@@ -271,7 +271,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
for name, stmt in node.items():
if is_inside_except(stmt):
continue
- if name in globs and not isinstance(stmt, astng.Global):
+ if name in globs and not isinstance(stmt, astroid.Global):
line = globs[name][0].fromlineno
self.add_message('W0621', args=(name, line), node=stmt)
elif is_builtin(name):
@@ -301,7 +301,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
# ignore names imported by the global statement
# FIXME: should only ignore them if it's assigned latter
stmt = stmts[0]
- if isinstance(stmt, astng.Global):
+ if isinstance(stmt, astroid.Global):
continue
# care about functions with unknown argument (builtins)
if name in argnames:
@@ -328,7 +328,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
def visit_global(self, node):
"""check names imported exists in the global scope"""
frame = node.frame()
- if isinstance(frame, astng.Module):
+ if isinstance(frame, astroid.Module):
self.add_message('W0604', node=node)
return
module = frame.root()
@@ -336,7 +336,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
for name in node.names:
try:
assign_nodes = module.getattr(name)
- except astng.NotFoundError:
+ except astroid.NotFoundError:
# unassigned global, skip
assign_nodes = []
for anode in assign_nodes:
@@ -399,7 +399,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
astmts = _astmts
if len(astmts) == 1:
ass = astmts[0].ass_type()
- if isinstance(ass, (astng.For, astng.Comprehension, astng.GenExpr)) \
+ if isinstance(ass, (astroid.For, astroid.Comprehension, astroid.GenExpr)) \
and not ass.statement() is node.statement():
self.add_message('W0631', args=name, node=node)
@@ -410,7 +410,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
self.add_message('W0623', args=args, node=name)
def visit_assname(self, node):
- if isinstance(node.ass_type(), astng.AugAssign):
+ if isinstance(node.ass_type(), astroid.AugAssign):
self.visit_name(node)
def visit_delname(self, node):
@@ -422,7 +422,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
"""
stmt = node.statement()
if stmt.fromlineno is None:
- # name node from a astng built from live code, skip
+ # name node from a astroid built from live code, skip
assert not stmt.root().file.endswith('.py')
return
name = node.name
@@ -481,13 +481,13 @@ builtins. Remember that you should avoid to define new builtins when possible.'
and stmt.fromlineno <= defstmt.fromlineno
and not is_defined_before(node)
and not are_exclusive(stmt, defstmt, ('NameError', 'Exception', 'BaseException'))):
- if defstmt is stmt and isinstance(node, (astng.DelName,
- astng.AssName)):
+ if defstmt is stmt and isinstance(node, (astroid.DelName,
+ astroid.AssName)):
self.add_message('E0602', args=name, node=node)
elif self._to_consume[-1][-1] != 'lambda':
# E0601 may *not* occurs in lambda scope
self.add_message('E0601', args=name, node=node)
- if not isinstance(node, astng.AssName): # Aug AssName
+ if not isinstance(node, astroid.AssName): # Aug AssName
del to_consume[name]
else:
del consumed[name]
@@ -497,7 +497,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
else:
# we have not found the name, if it isn't a builtin, that's an
# undefined name !
- if not (name in astng.Module.scope_attrs or is_builtin(name)
+ if not (name in astroid.Module.scope_attrs or is_builtin(name)
or name in self.config.additional_builtins):
self.add_message('E0602', args=name, node=node)
@@ -508,7 +508,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
parts = name.split('.')
try:
module = node.infer_name_module(parts[0]).next()
- except astng.ResolveError:
+ except astroid.ResolveError:
continue
self._check_module_attrs(node, module, parts[1:])
@@ -519,7 +519,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
level = getattr(node, 'level', None)
try:
module = node.root().import_module(name_parts[0], level=level)
- except ASTNGBuildingException:
+ except AstroidBuildingException:
return
except Exception, exc:
print 'Unhandled exception in VariablesChecker:', exc
@@ -537,7 +537,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
given module
if the latest access name corresponds to a module, return it
"""
- assert isinstance(module, astng.Module), module
+ assert isinstance(module, astroid.Module), module
while module_names:
name = module_names.pop(0)
if name == '__dict__':
@@ -545,12 +545,12 @@ builtins. Remember that you should avoid to define new builtins when possible.'
break
try:
module = module.getattr(name)[0].infer().next()
- if module is astng.YES:
+ if module is astroid.YES:
return None
- except astng.NotFoundError:
+ except astroid.NotFoundError:
self.add_message('E0611', args=(name, module.name), node=node)
return None
- except astng.InferenceError:
+ except astroid.InferenceError:
return None
if module_names:
# FIXME: other message if name is not the latest part of
@@ -559,7 +559,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
self.add_message('E0611', node=node,
args=('.'.join(module_names), modname))
return None
- if isinstance(module, astng.Module):
+ if isinstance(module, astroid.Module):
return module
return None
diff --git a/doc/contribute.rst b/doc/contribute.rst
index d62a504..d938ec5 100644
--- a/doc/contribute.rst
+++ b/doc/contribute.rst
@@ -22,9 +22,9 @@ python code.
Note that if you don't find something you have expected in Pylint's
issue tracker, it may be because it is an issue with one of its dependencies, namely
-astng and common:
+astroid and logilab-common:
-* https://bitbucket.org/logilab/astng
+* https://bitbucket.org/logilab/astroid
* http://www.logilab.org/project/logilab-common
Mailing lists
@@ -52,7 +52,7 @@ Pylint is developped using the mercurial_ distributed version control system.
You can clone Pylint and its dependencies from ::
hg clone https://bitbucket.org/logilab/pylint
- hg clone https://bitbucket.org/logilab/astng
+ hg clone https://bitbucket.org/logilab/astroid
hg clone http://hg.logilab.org/logilab/common
.. _mercurial: http://www.selenic.com/mercurial/
diff --git a/doc/faq.rst b/doc/faq.rst
index 15de8c5..ce5102d 100644
--- a/doc/faq.rst
+++ b/doc/faq.rst
@@ -64,10 +64,10 @@ Pylint from the repository, simply invoke ::
2.3 What are Pylint's dependencies?
-----------------------------------
-Pylint requires the latest `astng`_ and `logilab-common`_ packages. It should be
+Pylint requires the latest `astroid`_ and `logilab-common`_ packages. It should be
compatible with any Python version greater than 2.5.0.
-.. _`astng`: https://bitbucket.org/logilab/astng
+.. _`astroid`: https://bitbucket.org/logilab/astroid
.. _`logilab-common`: http://www.logilab.org/project/logilab-common
diff --git a/doc/installation.rst b/doc/installation.rst
index 976b28b..5992bfc 100644
--- a/doc/installation.rst
+++ b/doc/installation.rst
@@ -5,10 +5,10 @@ Installation
Dependencies
''''''''''''
-Pylint requires the latest `astng`_ and `logilab-common`_
+Pylint requires the latest `astroid`_ and `logilab-common`_
packages. It should be compatible with any Python version >= 2.5.
-.. _`astng`: https://bitbucket.org/logilab/astng
+.. _`astroid`: https://bitbucket.org/logilab/astroid
.. _`logilab-common`: http://www.logilab.org/project/logilab-common
diff --git a/examples/custom.py b/examples/custom.py
index 7e4d5e7..2537bad 100644
--- a/examples/custom.py
+++ b/examples/custom.py
@@ -1,14 +1,14 @@
-from logilab import astng
+import astroid
-from pylint.interfaces import IASTNGChecker
+from pylint.interfaces import IAstroidChecker
from pylint.checkers import BaseChecker
-class MyASTNGChecker(BaseChecker):
+class MyAstroidChecker(BaseChecker):
"""add member attributes defined using my own "properties" function
to the class locals dictionary
"""
- __implements__ = IASTNGChecker
+ __implements__ = IAstroidChecker
name = 'custom'
msgs = {}
@@ -19,9 +19,9 @@ class MyASTNGChecker(BaseChecker):
def visit_callfunc(self, node):
"""called when a CallFunc node is encountered.
- See logilab.astng for the description of available nodes."""
- if not (isinstance(node.func, astng.Getattr)
- and isinstance(node.func.expr, astng.Name)
+ See astroid for the description of available nodes."""
+ if not (isinstance(node.func, astroid.Getattr)
+ and isinstance(node.func.expr, astroid.Name)
and node.func.expr.name == 'properties'
and node.func.attrname == 'create'):
return
@@ -32,5 +32,5 @@ class MyASTNGChecker(BaseChecker):
def register(linter):
"""required method to auto register this checker"""
- linter.register_checker(MyASTNGChecker(linter))
+ linter.register_checker(MyAstroidChecker(linter))
diff --git a/interfaces.py b/interfaces.py
index a24e36f..f3f7591 100644
--- a/interfaces.py
+++ b/interfaces.py
@@ -43,10 +43,10 @@ class IRawChecker(IChecker):
"""interface for checker which need to parse the raw file
"""
- def process_module(self, astng):
+ def process_module(self, astroid):
""" process a module
- the module's content is accessible via astng.file_stream
+ the module's content is accessible via astroid.file_stream
"""
@@ -59,7 +59,7 @@ class ITokenChecker(IChecker):
"""
-class IASTNGChecker(IChecker):
+class IAstroidChecker(IChecker):
""" interface for checker which prefers receive events according to
statement type
"""
@@ -75,7 +75,7 @@ class ILinter(Interface):
def register_checker(self, checker):
"""register a new checker class
- checker is a class implementing IrawChecker or / and IASTNGChecker
+ checker is a class implementing IrawChecker or / and IAstroidChecker
"""
def add_message(self, msg_id, line=None, node=None, args=None):
@@ -83,7 +83,7 @@ class ILinter(Interface):
If provided, msg is expanded using args
- astng checkers should provide the node argument,
+ astroid checkers should provide the node argument,
raw checkers should provide the line argument.
"""
diff --git a/lint.py b/lint.py
index a91422b..6fe9076 100644
--- a/lint.py
+++ b/lint.py
@@ -43,13 +43,13 @@ from logilab.common.textutils import splitstrip
from logilab.common.ureports import Table, Text, Section
from logilab.common.__pkginfo__ import version as common_version
-from logilab.astng import MANAGER, nodes, ASTNGBuildingException
-from logilab.astng.__pkginfo__ import version as astng_version
+from astroid import MANAGER, nodes, AstroidBuildingException
+from astroid.__pkginfo__ import version as astroid_version
from pylint.utils import (PyLintASTWalker, UnknownMessage, MessagesHandlerMixIn,
ReportsHandlerMixIn, MSG_TYPES, expand_modules,
WarningScope, tokenize_module)
-from pylint.interfaces import ILinter, IRawChecker, ITokenChecker, IASTNGChecker
+from pylint.interfaces import ILinter, IRawChecker, ITokenChecker, IAstroidChecker
from pylint.checkers import (BaseTokenChecker, EmptyReport,
table_lines_from_stats)
from pylint.reporters.text import (TextReporter, ParseableTextReporter,
@@ -88,8 +88,8 @@ MSGS = {
'Used when an error occurred preventing the analysis of a \
module (unable to find it for instance).'),
'F0002': ('%s: %s',
- 'astng-error',
- 'Used when an unexpected error occurred while building the ASTNG \
+ 'astroid-error',
+ 'Used when an unexpected error occurred while building the Astroid \
representation. This is usually accompanied by a traceback. \
Please report such errors !'),
'F0003': ('ignored builtin module %s',
@@ -102,8 +102,8 @@ MSGS = {
inferred.'),
'F0010': ('error while code parsing: %s',
'parse-error',
- 'Used when an exception occured while building the ASTNG \
- representation which could be handled by astng.'),
+ 'Used when an exception occured while building the Astroid \
+ representation which could be handled by astroid.'),
'I0001': ('Unable to run raw checkers on built-in module %s',
'raw-checker-failed',
@@ -161,13 +161,13 @@ class PyLinter(OptionsManagerMixIn, MessagesHandlerMixIn, ReportsHandlerMixIn,
"""lint Python modules using external checkers.
This is the main checker controlling the other ones and the reports
- generation. It is itself both a raw checker and an astng checker in order
+ generation. It is itself both a raw checker and an astroid checker in order
to:
* handle message activation / deactivation at the module level
* handle some basic but necessary stats'data (number of classes, methods...)
IDE plugins developpers: you may have to call
- `logilab.astng.builder.MANAGER.astng_cache.clear()` accross run if you want
+ `astroid.builder.MANAGER.astroid_cache.clear()` accross run if you want
to ensure the latest code version is actually checked.
"""
@@ -285,7 +285,7 @@ This is used by the global evaluation report (RP0004).'}),
pylintrc=None):
# some stuff has to be done before ancestors initialization...
#
- # checkers / reporter / astng manager
+ # checkers / reporter / astroid manager
self.reporter = None
self._checkers = {}
self._ignore_file = False
@@ -303,8 +303,8 @@ This is used by the global evaluation report (RP0004).'}),
'disable': self.disable}
self._bw_options_methods = {'disable-msg': self.disable,
'enable-msg': self.enable}
- full_version = '%%prog %s, \nastng %s, common %s\nPython %s' % (
- version, astng_version, common_version, sys.version)
+ full_version = '%%prog %s, \nastroid %s, common %s\nPython %s' % (
+ version, astroid_version, common_version, sys.version)
OptionsManagerMixIn.__init__(self, usage=__doc__,
version=full_version,
config_file=pylintrc or config.PYLINTRC)
@@ -395,7 +395,7 @@ This is used by the global evaluation report (RP0004).'}),
def register_checker(self, checker):
"""register a new checker
- checker is an object implementing IRawChecker or / and IASTNGChecker
+ checker is an object implementing IRawChecker or / and IAstroidChecker
"""
assert checker.priority <= 0, 'checker priority can\'t be >= 0'
self._checkers.setdefault(checker.name, []).append(checker)
@@ -571,7 +571,7 @@ This is used by the global evaluation report (RP0004).'}),
# notify global begin
for checker in checkers:
checker.open()
- if implements(checker, IASTNGChecker):
+ if implements(checker, IAstroidChecker):
walker.add_checker(checker)
# build ast and check modules or packages
for descr in self.expand_files(files_or_modules):
@@ -581,16 +581,16 @@ This is used by the global evaluation report (RP0004).'}),
self.reporter.set_output(open(reportfile, 'w'))
self.set_current_module(modname, filepath)
# get the module representation
- astng = self.get_astng(filepath, modname)
- if astng is None:
+ astroid = self.get_astroid(filepath, modname)
+ if astroid is None:
continue
self.base_name = descr['basename']
self.base_file = descr['basepath']
self._ignore_file = False
# fix the current file (if the source file was not available or
# if it's actually a c extension)
- self.current_file = astng.file
- self.check_astng_module(astng, walker, rawcheckers, tokencheckers)
+ self.current_file = astroid.file
+ self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
self._add_suppression_messages()
# notify global end
self.set_current_module('')
@@ -633,28 +633,28 @@ This is used by the global evaluation report (RP0004).'}),
self._raw_module_msgs_state = {}
self._ignored_msgs = {}
- def get_astng(self, filepath, modname):
- """return a astng representation for a module"""
+ def get_astroid(self, filepath, modname):
+ """return a astroid representation for a module"""
try:
- return MANAGER.astng_from_file(filepath, modname, source=True)
+ return MANAGER.astroid_from_file(filepath, modname, source=True)
except SyntaxError, ex:
self.add_message('E0001', line=ex.lineno, args=ex.msg)
- except ASTNGBuildingException, ex:
+ except AstroidBuildingException, ex:
self.add_message('F0010', args=ex)
except Exception, ex:
import traceback
traceback.print_exc()
self.add_message('F0002', args=(ex.__class__, ex))
- def check_astng_module(self, astng, walker, rawcheckers, tokencheckers):
- """check a module from its astng representation, real work"""
+ def check_astroid_module(self, astroid, walker, rawcheckers, tokencheckers):
+ """check a module from its astroid representation, real work"""
# call raw checkers if possible
- tokens = tokenize_module(astng)
+ tokens = tokenize_module(astroid)
- if not astng.pure_python:
- self.add_message('I0001', args=astng.name)
+ if not astroid.pure_python:
+ self.add_message('I0001', args=astroid.name)
else:
- #assert astng.file.endswith('.py')
+ #assert astroid.file.endswith('.py')
# invoke ITokenChecker interface on self to fetch module/block
# level options
self.process_tokens(tokens)
@@ -666,16 +666,16 @@ This is used by the global evaluation report (RP0004).'}),
orig_state = self._module_msgs_state.copy()
self._module_msgs_state = {}
self._suppression_mapping = {}
- self.collect_block_lines(astng, orig_state)
+ self.collect_block_lines(astroid, orig_state)
for checker in rawcheckers:
- checker.process_module(astng)
+ checker.process_module(astroid)
for checker in tokencheckers:
checker.process_tokens(tokens)
- # generate events to astng checkers
- walker.walk(astng)
+ # generate events to astroid checkers
+ walker.walk(astroid)
return True
- # IASTNGChecker interface #################################################
+ # IAstroidChecker interface #################################################
def open(self):
"""initialize counters"""
diff --git a/pyreverse/diadefslib.py b/pyreverse/diadefslib.py
index 68ca68c..ebdf095 100644
--- a/pyreverse/diadefslib.py
+++ b/pyreverse/diadefslib.py
@@ -18,8 +18,8 @@
from logilab.common.compat import builtins
BUILTINS_NAME = builtins.__name__
-from logilab import astng
-from logilab.astng.utils import LocalsVisitor
+import astroid
+from astroid.utils import LocalsVisitor
from pylint.pyreverse.diagrams import PackageDiagram, ClassDiagram
@@ -100,9 +100,9 @@ class DiaDefGenerator:
for ass_nodes in klass_node.instance_attrs_type.values() + \
klass_node.locals_type.values():
for ass_node in ass_nodes:
- if isinstance(ass_node, astng.Instance):
+ if isinstance(ass_node, astroid.Instance):
ass_node = ass_node._proxied
- if not (isinstance(ass_node, astng.Class)
+ if not (isinstance(ass_node, astroid.Class)
and self.show_node(ass_node)):
continue
yield ass_node
@@ -132,7 +132,7 @@ class DefaultDiadefGenerator(LocalsVisitor, DiaDefGenerator):
LocalsVisitor.__init__(self)
def visit_project(self, node):
- """visit an astng.Project node
+ """visit an astroid.Project node
create a diagram definition for packages
"""
@@ -144,7 +144,7 @@ class DefaultDiadefGenerator(LocalsVisitor, DiaDefGenerator):
self.classdiagram = ClassDiagram('classes %s' % node.name, mode)
def leave_project(self, node):
- """leave the astng.Project node
+ """leave the astroid.Project node
return the generated diagram definition
"""
@@ -153,7 +153,7 @@ class DefaultDiadefGenerator(LocalsVisitor, DiaDefGenerator):
return self.classdiagram,
def visit_module(self, node):
- """visit an astng.Module node
+ """visit an astroid.Module node
add this class to the package diagram definition
"""
@@ -162,7 +162,7 @@ class DefaultDiadefGenerator(LocalsVisitor, DiaDefGenerator):
self.pkgdiagram.add_object(node.name, node)
def visit_class(self, node):
- """visit an astng.Class node
+ """visit an astroid.Class node
add this class to the class diagram definition
"""
@@ -170,7 +170,7 @@ class DefaultDiadefGenerator(LocalsVisitor, DiaDefGenerator):
self.extract_classes(node, anc_level, ass_level)
def visit_from(self, node):
- """visit astng.From and catch modules for package diagram
+ """visit astroid.From and catch modules for package diagram
"""
if self.pkgdiagram:
self.pkgdiagram.add_from_depend(node, node.modname)
@@ -215,8 +215,8 @@ class DiadefsHandler:
def get_diadefs(self, project, linker):
"""get the diagrams configuration data
- :param linker: astng.inspector.Linker(IdGeneratorMixIn, LocalsVisitor)
- :param project: astng.manager.Project
+ :param linker: astroid.inspector.Linker(IdGeneratorMixIn, LocalsVisitor)
+ :param project: astroid.manager.Project
"""
# read and interpret diagram definitions (Diadefs)
diff --git a/pyreverse/diagrams.py b/pyreverse/diagrams.py
index b411bd0..7cb5930 100644
--- a/pyreverse/diagrams.py
+++ b/pyreverse/diagrams.py
@@ -16,7 +16,7 @@
"""diagram objects
"""
-from logilab import astng
+import astroid
from pylint.pyreverse.utils import is_interface, FilterMixIn
def set_counter(value):
@@ -42,7 +42,7 @@ class Relationship(Figure):
class DiagramEntity(Figure):
- """a diagram object, i.e. a label associated to an astng node
+ """a diagram object, i.e. a label associated to an astroid node
"""
def __init__(self, title='No name', node=None):
Figure.__init__(self)
@@ -93,7 +93,7 @@ class ClassDiagram(Figure, FilterMixIn):
def get_methods(self, node):
"""return visible methods"""
return [m for m in node.values()
- if isinstance(m, astng.Function) and self.show_attr(m.name)]
+ if isinstance(m, astroid.Function) and self.show_attr(m.name)]
def add_object(self, title, node):
"""create a diagram object
@@ -107,9 +107,9 @@ class ClassDiagram(Figure, FilterMixIn):
"""return class names if needed in diagram"""
names = []
for ass_node in nodes:
- if isinstance(ass_node, astng.Instance):
+ if isinstance(ass_node, astroid.Instance):
ass_node = ass_node._proxied
- if isinstance(ass_node, astng.Class) \
+ if isinstance(ass_node, astroid.Class) \
and hasattr(ass_node, "name") and not self.has_node(ass_node):
if ass_node.name not in names:
ass_name = ass_node.name
@@ -133,7 +133,7 @@ class ClassDiagram(Figure, FilterMixIn):
def classes(self):
"""return all class nodes in the diagram"""
- return [o for o in self.objects if isinstance(o.node, astng.Class)]
+ return [o for o in self.objects if isinstance(o.node, astroid.Class)]
def classe(self, name):
"""return a class by its name, raise KeyError if not found
@@ -173,9 +173,9 @@ class ClassDiagram(Figure, FilterMixIn):
for name, values in node.instance_attrs_type.items() + \
node.locals_type.items():
for value in values:
- if value is astng.YES:
+ if value is astroid.YES:
continue
- if isinstance( value, astng.Instance):
+ if isinstance( value, astroid.Instance):
value = value._proxied
try:
ass_obj = self.object_from_node(value)
@@ -191,7 +191,7 @@ class PackageDiagram(ClassDiagram):
def modules(self):
"""return all module nodes in the diagram"""
- return [o for o in self.objects if isinstance(o.node, astng.Module)]
+ return [o for o in self.objects if isinstance(o.node, astroid.Module)]
def module(self, name):
"""return a module by its name, raise KeyError if not found
diff --git a/pyreverse/main.py b/pyreverse/main.py
index 4e4458c..cdd6607 100644
--- a/pyreverse/main.py
+++ b/pyreverse/main.py
@@ -21,8 +21,8 @@
import sys, os
from logilab.common.configuration import ConfigurationMixIn
-from logilab.astng.manager import ASTNGManager
-from logilab.astng.inspector import Linker
+from astroid.manager import AstroidManager
+from astroid.inspector import Linker
from pylint.pyreverse.diadefslib import DiadefsHandler
from pylint.pyreverse import writer
@@ -92,7 +92,7 @@ class Run(ConfigurationMixIn):
def __init__(self, args):
ConfigurationMixIn.__init__(self, usage=__doc__)
insert_default_options()
- self.manager = ASTNGManager()
+ self.manager = AstroidManager()
self.register_options_provider(self.manager)
args = self.load_command_line_configuration()
sys.exit(self.run(args))
diff --git a/pyreverse/utils.py b/pyreverse/utils.py
index ea8b67c..58263b6 100644
--- a/pyreverse/utils.py
+++ b/pyreverse/utils.py
@@ -50,7 +50,7 @@ def insert_default_options():
-# astng utilities ###########################################################
+# astroid utilities ###########################################################
SPECIAL = re.compile('^__[A-Za-z0-9]+[A-Za-z0-9_]*__$')
PRIVATE = re.compile('^__[_A-Za-z0-9]*[A-Za-z0-9]+_?$')
diff --git a/test/input/func_f0001.py b/test/input/func_f0001.py
index af6de24..b0e559a 100644
--- a/test/input/func_f0001.py
+++ b/test/input/func_f0001.py
@@ -1,4 +1,4 @@
-"""test astng error
+"""test astroid error
"""
import whatever
__revision__ = None
diff --git a/test/input/func_noerror_factory_method.py b/test/input/func_noerror_factory_method.py
index bd24479..c445d69 100644
--- a/test/input/func_noerror_factory_method.py
+++ b/test/input/func_noerror_factory_method.py
@@ -1,5 +1,5 @@
# pylint: disable=R0903
-"""use new astng context sensitive inference"""
+"""use new astroid context sensitive inference"""
__revision__ = 1
class Super(object):
diff --git a/test/input/func_noerror_nonregr.py b/test/input/func_noerror_nonregr.py
index 35598e0..992f9f3 100644
--- a/test/input/func_noerror_nonregr.py
+++ b/test/input/func_noerror_nonregr.py
@@ -5,7 +5,7 @@ __revision__ = 1
def function1(cbarg = lambda: None):
"""
- File "/usr/lib/python2.4/site-packages/logilab/astng/scoped_nodes.py", line
+ File "/usr/lib/python2.4/site-packages/logilab/astroid/scoped_nodes.py", line
391, in mularg_class # this method doesn't exist anymore
i = self.args.args.index(argname)
ValueError: list.index(x): x not in list
diff --git a/test/input/func_noerror_socket_member.py b/test/input/func_noerror_socket_member.py
index 8c79ff5..ffa3e9c 100644
--- a/test/input/func_noerror_socket_member.py
+++ b/test/input/func_noerror_socket_member.py
@@ -7,7 +7,7 @@ Version used:
- Pylint 0.10.0
- Logilab common 0.15.0
- - Logilab astng 0.15.1
+ - Logilab astroid 0.15.1
False E1101 positive, line 23:
diff --git a/test/input/func_undefined_var.py b/test/input/func_undefined_var.py
index 27a9ed6..1affd6c 100644
--- a/test/input/func_undefined_var.py
+++ b/test/input/func_undefined_var.py
@@ -15,7 +15,7 @@ def in_method(var):
assert var
DEFINED = {DEFINED:__revision__}
-DEFINED[__revision__] = OTHER = 'move this is astng test'
+DEFINED[__revision__] = OTHER = 'move this is astroid test'
OTHER += '$'
diff --git a/test/regrtest_data/decimal_inference.py b/test/regrtest_data/decimal_inference.py
index 1b97f60..b47bc1c 100644
--- a/test/regrtest_data/decimal_inference.py
+++ b/test/regrtest_data/decimal_inference.py
@@ -1,7 +1,7 @@
"""hum E1011 on .prec member is justifiable since Context instance are built
using setattr/locals :(
-2007/02/17 update: .prec attribute is now detected by astng :o)
+2007/02/17 update: .prec attribute is now detected by astroid :o)
"""
import decimal
diff --git a/test/regrtest_data/import_package_subpackage_module.py b/test/regrtest_data/import_package_subpackage_module.py
index a1d4747..937c8c3 100644
--- a/test/regrtest_data/import_package_subpackage_module.py
+++ b/test/regrtest_data/import_package_subpackage_module.py
@@ -1,6 +1,6 @@
# pylint: disable=I0011,C0301,W0611
"""I found some of my scripts trigger off an AttributeError in pylint
-0.8.1 (with common 0.12.0 and astng 0.13.1).
+0.8.1 (with common 0.12.0 and astroid 0.13.1).
Traceback (most recent call last):
File "/usr/bin/pylint", line 4, in ?
@@ -10,18 +10,18 @@ Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 412, in check
self.check_file(filepath, modname, checkers)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 426, in check_file
- astng = self._check_file(filepath, modname, checkers)
+ astroid = self._check_file(filepath, modname, checkers)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 450, in _check_file
- self.check_astng_module(astng, checkers)
- File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 494, in check_astng_module
- self.astng_events(astng, [checker for checker in checkers
- File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astng_events
- self.astng_events(child, checkers, _reversed_checkers)
- File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astng_events
- self.astng_events(child, checkers, _reversed_checkers)
- File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 508, in astng_events
- checker.visit(astng)
- File "/usr/lib/python2.4/site-packages/logilab/astng/utils.py", line 84, in visit
+ self.check_astroid_module(astroid, checkers)
+ File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 494, in check_astroid_module
+ self.astroid_events(astroid, [checker for checker in checkers
+ File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events
+ self.astroid_events(child, checkers, _reversed_checkers)
+ File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events
+ self.astroid_events(child, checkers, _reversed_checkers)
+ File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 508, in astroid_events
+ checker.visit(astroid)
+ File "/usr/lib/python2.4/site-packages/logilab/astroid/utils.py", line 84, in visit
method(node)
File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 295, in visit_import
self._check_module_attrs(node, module, name_parts[1:])
diff --git a/test/regrtest_data/pygtk_enum_crash.py b/test/regrtest_data/pygtk_enum_crash.py
index 8ac9e57..471afe3 100644
--- a/test/regrtest_data/pygtk_enum_crash.py
+++ b/test/regrtest_data/pygtk_enum_crash.py
@@ -4,8 +4,8 @@
import gtk
def print_some_constant(arg=gtk.BUTTONS_OK):
- """crash because gtk.BUTTONS_OK, a gtk enum type, is returned by astng as a
- constant
+ """crash because gtk.BUTTONS_OK, a gtk enum type, is returned by
+ astroid as a constant
"""
print arg
diff --git a/test/unittest_lint.py b/test/unittest_lint.py
index 94c0b03..897c66f 100644
--- a/test/unittest_lint.py
+++ b/test/unittest_lint.py
@@ -153,12 +153,12 @@ class PyLinterTC(TestCase):
linter.open()
filepath = join(INPUTDIR, 'func_block_disable_msg.py')
linter.set_current_module('func_block_disable_msg')
- astng = linter.get_astng(filepath, 'func_block_disable_msg')
- linter.process_tokens(tokenize_module(astng))
+ astroid = linter.get_astroid(filepath, 'func_block_disable_msg')
+ linter.process_tokens(tokenize_module(astroid))
orig_state = linter._module_msgs_state.copy()
linter._module_msgs_state = {}
linter._suppression_mapping = {}
- linter.collect_block_lines(astng, orig_state)
+ linter.collect_block_lines(astroid, orig_state)
# global (module level)
self.assertTrue(linter.is_message_enabled('W0613'))
self.assertTrue(linter.is_message_enabled('E1101'))
diff --git a/test/unittest_pyreverse_diadefs.py b/test/unittest_pyreverse_diadefs.py
index 21ded47..ebcf371 100644
--- a/test/unittest_pyreverse_diadefs.py
+++ b/test/unittest_pyreverse_diadefs.py
@@ -20,25 +20,25 @@ unittest for the extensions.diadefslib modules
import unittest
import sys
-from logilab import astng
-from logilab.astng import MANAGER
-from logilab.astng.inspector import Linker
+import astroid
+from astroid import MANAGER
+from astroid.inspector import Linker
from pylint.pyreverse.diadefslib import *
from utils import Config
-def astng_wrapper(func, modname):
+def astroid_wrapper(func, modname):
return func(modname)
-PROJECT = MANAGER.project_from_files(['data'], astng_wrapper)
+PROJECT = MANAGER.project_from_files(['data'], astroid_wrapper)
CONFIG = Config()
HANDLER = DiadefsHandler(CONFIG)
def _process_classes(classes):
"""extract class names of a list"""
- return sorted([(isinstance(c.node, astng.Class), c.title) for c in classes])
+ return sorted([(isinstance(c.node, astroid.Class), c.title) for c in classes])
def _process_relations(relations):
"""extract relation indices from a relation list"""
@@ -95,7 +95,7 @@ class DefaultDiadefGeneratorTC(unittest.TestCase):
self.assertEqual(keys, ['package', 'class'])
pd = dd[0]
self.assertEqual(pd.title, 'packages No Name')
- modules = sorted([(isinstance(m.node, astng.Module), m.title)
+ modules = sorted([(isinstance(m.node, astroid.Module), m.title)
for m in pd.objects])
self.assertEqual(modules, [(True, 'data'),
(True, 'data.clientmodule_test'),
@@ -125,7 +125,7 @@ class DefaultDiadefGeneratorTC(unittest.TestCase):
different classes possibly in different modules"""
# XXX should be catching pyreverse environnement problem but doesn't
# pyreverse doesn't extracts the relations but this test ok
- project = MANAGER.project_from_files(['data'], astng_wrapper)
+ project = MANAGER.project_from_files(['data'], astroid_wrapper)
handler = DiadefsHandler( Config() )
diadefs = handler.get_diadefs(project, Linker(project, tag=True) )
cd = diadefs[1]
@@ -133,7 +133,7 @@ class DefaultDiadefGeneratorTC(unittest.TestCase):
self.assertEqual(relations, self._should_rels)
def test_known_values2(self):
- project = MANAGER.project_from_files(['data.clientmodule_test'], astng_wrapper)
+ project = MANAGER.project_from_files(['data.clientmodule_test'], astroid_wrapper)
dd = DefaultDiadefGenerator(Linker(project), HANDLER).visit(project)
self.assertEqual(len(dd), 1)
keys = [d.TYPE for d in dd]
diff --git a/test/unittest_pyreverse_writer.py b/test/unittest_pyreverse_writer.py
index 3ccc231..a4e283e 100644
--- a/test/unittest_pyreverse_writer.py
+++ b/test/unittest_pyreverse_writer.py
@@ -18,7 +18,7 @@ unittest for visitors.diadefs and extensions.diadefslib modules
"""
from os.path import abspath, dirname, join
-from logilab.astng.inspector import Linker
+from astroid.inspector import Linker
from logilab.common.testlib import TestCase, unittest_main
from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
diff --git a/test/utils.py b/test/utils.py
index 3cf1699..6722e32 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -6,10 +6,10 @@ import sys
from os.path import join, dirname, abspath
from logilab.common.testlib import TestCase
-from logilab.astng import MANAGER
+from astroid import MANAGER
-def _astng_wrapper(func, modname):
+def _astroid_wrapper(func, modname):
return func(modname)
@@ -22,12 +22,12 @@ def _sorted_file(path):
return '\n'.join(lines)
def get_project(module, name=None):
- """return a astng project representation
+ """return a astroid project representation
"""
manager = MANAGER
# flush cache
manager._modules_by_name = {}
- return manager.project_from_files([module], _astng_wrapper,
+ return manager.project_from_files([module], _astroid_wrapper,
project_name=name)
DEFAULTS = {'all_ancestors': None, 'show_associated': None,
diff --git a/utils.py b/utils.py
index 370d25e..b48717d 100644
--- a/utils.py
+++ b/utils.py
@@ -29,7 +29,7 @@ from logilab.common.textutils import normalize_text
from logilab.common.configuration import rest_format_section
from logilab.common.ureports import Section
-from logilab.astng import nodes, Module
+from astroid import nodes, Module
from pylint.checkers import EmptyReport
from pylint.interfaces import IRawChecker, ITokenChecker
@@ -348,7 +348,7 @@ class MessagesHandlerMixIn(object):
If provided, msg is expanded using args
- astng checkers should provide the node argument, raw checkers should
+ astroid checkers should provide the node argument, raw checkers should
provide the line argument.
"""
msg_info = self._messages[msgid]
@@ -627,18 +627,18 @@ class PyLintASTWalker(object):
visits.setdefault(cid, []).append(visit_default)
# for now we have no "leave_default" method in Pylint
- def walk(self, astng):
- """call visit events of astng checkers for the given node, recurse on
+ def walk(self, astroid):
+ """call visit events of astroid checkers for the given node, recurse on
its children, then leave events.
"""
- cid = astng.__class__.__name__.lower()
- if astng.is_statement:
+ cid = astroid.__class__.__name__.lower()
+ if astroid.is_statement:
self.nbstatements += 1
# generate events for this node on each checker
for cb in self.visit_events.get(cid, ()):
- cb(astng)
+ cb(astroid)
# recurse on children
- for child in astng.get_children():
+ for child in astroid.get_children():
self.walk(child)
for cb in self.leave_events.get(cid, ()):
- cb(astng)
+ cb(astroid)