Coder Social home page Coder Social logo

pylint-dev / astroid Goto Github PK

View Code? Open in Web Editor NEW
510.0 25.0 261.0 16.01 MB

A common base representation of python source code for pylint and other projects

Home Page: https://pylint.readthedocs.io/projects/astroid/en/latest/

License: GNU Lesser General Public License v2.1

Python 100.00%
ast parser inference-engine closember hacktoberfest static-code-analysis static-analysis

astroid's People

Contributors

alexmojaki avatar awhetter avatar brycepg avatar cdce8p avatar ceridwen avatar cpennington avatar danielnoord avatar david-yz-liu avatar dependabot[bot] avatar dgilman avatar dimp-gh avatar eevee avatar flying-sheep avatar github-actions[bot] avatar gurneyalex avatar hippo91 avatar hugovk avatar jacobtylerwalls avatar jcristau avatar mbyrnepr2 avatar nelfin avatar nickdrozd avatar pcmanticore avatar pierre-sassoulas avatar pre-commit-ci[bot] avatar rogalski avatar the-compiler avatar tmarek-google avatar torstenmarek avatar tushar-deepsource avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

astroid's Issues

Python 3: Pylint can't check package source code in unicode format

Originally reported by: Nikolay Golub (BitBucket: ngolub)


I've moved my project to python 3 and my tests, which using pylint and httpretty fails with this error:

File "/usr/local/lib/python3.3/dist-packages/logilab/common/modutils.py", line 297, in file_from_modpath
return _file_from_modpath(modpath, path, context)`
File "/usr/local/lib/python3.3/dist-packages/logilab/common/modutils.py", line 556, in _file_from_modpath
mtype, mp_filename = _module_file(modpath, path)
File "/usr/local/lib/python3.3/dist-packages/logilab/common/modutils.py", line 663, in _module_file
data = stream.read(4096)
File "/usr/lib/python3.3/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 133: ordinal not in range(128)

I've found, that if fails on httpretty module indexing, because it contains:

#!/usr/bin/env python

-- coding: utf-8 --

<HTTPretty - HTTP client mock for Python>

Copyright (C) <2011-2013> Gabriel Falcão <...

Why pylint tries to decode utf-8 source as ascii?


Infinite loop in inference with decorators

Originally reported by: BitBucket: carlio, GitHub: @carlio?


If a decorator returns itself, type inference in Astroid can get into an infinite loop. The following will cause Pylint to stall forever:

def decorator():
    def wrapper():
        return decorator()
    return wrapper

@decorator()
def do_a_thing():
    print 'hello'

Here is a real-world example of this code: https://github.com/allegro/ralph/blob/develop/src/ralph/util/plugin.py#L25


1 test fail, test_socket_build, under pypy(2.0.2) in testsuite

Originally reported by: BitBucket: idella5


with
numpy-1.8.0
astroid-1.0.1
pypy-2.0.2

going into /mnt/gen2/TmpDir/portage/dev-python/astroid-1.0.1/work/astroid-1.0.1/test

======================================================================
ERROR: test_socket_build (unittest_builder.BuilderTC)
----------------------------------------------------------------------
Traceback (most recent call last)
  File "/usr/lib64/pypy2.0/site-packages/logilab/common/testlib.py", line 664, in _proceed
    testfunc(*args, **kwargs)
  File "/mnt/gen2/TmpDir/portage/dev-python/astroid-1.0.1/work/astroid-1.0.1/test/unittest_builder.py", line 442, in test_socket_build
    self.assertIn('connect', fclass)
  File "/usr/lib64/pypy2.0/lib-python/2.7/unittest/case.py", line 798, in assertIn
    if member not in container:
TypeError: '_Yes' object is not iterable

                              no stdout                               
                              no stderr                               

in gentoo linux

do you need anything else in the way of data?

----------------------------------------
- Bitbucket: https://bitbucket.org/logilab/astroid/issue/16

pygi plugin fails to detect glib with pygobject3-3.13.91

Originally reported by: Cole Robinson (BitBucket: crobinso, GitHub: @crobinso?)


The pygi plugin fails to detect glib with pygobject3-3.13.91. Example:

$ cat test.py

#!python

from gi.repository import GLib
from gi.repository import GObject

# These exist
print GLib.idle_add
print GObject.threads_init

# These don't exist
print GLib.foobarbaz
print GObject.bazbarfoo

$ pylint test.py --rcfile src/virt-manager/tests/pylint.cfg

#!bash

************* Module test
E:  1, 0: No name 'GLib' in module 'gi.repository' (no-name-in-module)
E: 10, 6: Module 'gi.repository.GObject' has no 'bazbarfoo' member (no-member)

I'll submit a patch shortly


test suite fails in -0.24.3 under py3.2, pypy

Originally reported by: BitBucket: idella5


firstly under py3.2; Python 3.2.4

pytest

yields

........E............
======================================================================
ERROR: test_generator_attributes (unittest_lookup.LookupTC)
----------------------------------------------------------------------
Traceback (most recent call last)
  File "/mnt/gen2/TmpDir/portage/dev-python/astng-0.24.3/work/logilab-astng-0.24.3-python3_2/test/lib/logilab_astng-0.24.3-py3.2.egg/logilab/astng/test/unittest_lookup.py", line 228, in test_generator_attributes
    self.assertIsInstance(gener.getattr('next')[0], Function)
  File "/usr/lib64/python3.2/site-packages/logilab/astng/bases.py", line 160, in getattr
    return self._proxied.getattr(name, context)
  File "/usr/lib64/python3.2/site-packages/logilab/astng/scoped_nodes.py", line 886, in getattr
    raise NotFoundError(name)
logilab.astng.exceptions.NotFoundError: next

                              no stdout                               
                              no stderr                               
______________________________________________
--------------------------------------------------------------------------
..S.F..
======================================================================
FAIL: test_numpy_crash (unittest_regrtest.NonRegressionTC)
test don't crash on numpy
----------------------------------------------------------------------
Traceback (most recent call last)
  File "/mnt/gen2/TmpDir/portage/dev-python/astng-0.24.3/work/logilab-astng-0.24.3-python3_2/test/lib/logilab_astng-0.24.3-py3.2.egg/logilab/astng/test/unittest_regrtest.py", line 136, in test_numpy_crash
    self.assertIsInstance(infered[0], Instance)
  File "/usr/lib64/python3.2/site-packages/logilab/common/testlib.py", line 1102, in assertIsInstance
    self.assertTrue(isinstance(obj, klass), msg)
  File "/usr/lib64/python3.2/unittest/case.py", line 506, in assertTrue
    raise self.failureException(msg)
AssertionError: False is not true : YES is not an instance of <class 'logilab.astng.bases.Instance'> but of <class 'logilab.astng.bases._Yes'>

                              no stdout                               
                              no stderr                               

Secondly pypy. The patch I made below resets the tests to yield a pass for pypy running them. Note "# no way for this one (is 4 actually)" in the test file implies you know of this oddity yet there it still sits. For py2.7 3.2 it passes but under pypy it yeilds these different data.

diff -ur logilab-astng-0.24.3.orig/test/unittest_builder.py logilab-astng-0.24.3/test/unittest_builder.py
--- test/unittest_builder.py    2013-04-17 17:38:31.000000000 +0800
+++ test/unittest_builder.py    2013-06-19 02:13:51.425269363 +0800
@@ -62,8 +62,12 @@
         self.assertEqual(name.tolineno, 4)
         strarg = callfunc.args[0]
         self.assertIsInstance(strarg, nodes.Const)
-        self.assertEqual(strarg.fromlineno, 5) # no way for this one (is 4 actually)
-        self.assertEqual(strarg.tolineno, 5)
+        if hasattr(sys, 'pypy_version_info'):
+            self.assertEqual(strarg.fromlineno, 4) # no way for this one (is 4 actually)
+            self.assertEqual(strarg.tolineno, 4)
+        else:
+            self.assertEqual(strarg.fromlineno, 5) # no way for this one (is 4 actually)
+            self.assertEqual(strarg.tolineno, 5)
         namearg = callfunc.args[1]
         self.assertIsInstance(namearg, nodes.Name)
         self.assertEqual(namearg.fromlineno, 5)
diff -ur logilab-astng-0.24.3.orig/test/unittest_inference.py logilab-astng-0.24.3/test/unittest_inference.py
--- test/unittest_inference.py  2013-04-17 17:38:31.000000000 +0800
+++ test/unittest_inference.py  2013-06-19 02:52:41.618270007 +0800
@@ -710,8 +710,12 @@
         node = get_name_node(astng, 'open', -1)
         infered = list(node.infer())
         self.assertEqual(len(infered), 1)
-        self.assertIsInstance(infered[0], nodes.Function)
-        self.assertEqual(infered[0].name, 'open')
+        if hasattr(sys, 'pypy_version_info'):
+            self.assertIsInstance(infered[0], nodes.Class)
+            self.assertEqual(infered[0].name, 'file')
+        else:
+            self.assertIsInstance(infered[0], nodes.Function)
+            self.assertEqual(infered[0].name, 'open')

     def test_callfunc_context_func(self):
         code = '''

The remaining test left to just fail is

.....S.......E..........................................
======================================================================
ERROR: test_socket_build (unittest_builder.BuilderTC)
----------------------------------------------------------------------
Traceback (most recent call last)
  File "/usr/lib64/pypy2.0/site-packages/logilab/common/testlib.py", line 661, in _proceed
    testfunc(*args, **kwargs)
  File "/mnt/gen2/TmpDir/portage/dev-python/astng-0.24.3/work/logilab-astng-0.24.3-pypy2_0/test/lib/logilab_astng-0.24.3-py2.7.egg/logilab/astng/test/unittest_builder.py", line 442, in test_socket_build
    self.assertIn('connect', fclass)
  File "/usr/lib64/pypy2.0/lib-python/2.7/unittest/case.py", line 798, in assertIn
    if member not in container:
TypeError: '_Yes' object is not iterable

                              no stdout                               
                              no stderr                               

It appears to me that pypy reading the ??same directory structure comes up with _Yes object, a valid astng object I gather but the wrong damned one.
There's a build log for you.

Over to you


AttributeError: 'Starred' object has no attribute 'assigned_stmts'

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


While testing https://bitbucket.org/logilab/pylint/pull-request/119/emit-an-error-when-a-list-index-is-a-non/, I discovered the following bug in astroid.

#!python

  File "C:\Python34\lib\site-packages\pylint-1.2.1-py3.4.egg\pylint\checkers\typecheck.py", line 544, in visit_index
    parent_type = safe_infer(node.parent.value)
  File "C:\Python34\lib\site-packages\pylint-1.2.1-py3.4.egg\pylint\checkers\utils.py", line 86, in safe_infer
    value = next(inferit)
  File "C:\Python34\lib\site-packages\astroid-1.1.1-py3.4.egg\astroid\bases.py", line 313, in wrapped
    for res in _func(node, context, **kwargs):
  File "C:\Python34\lib\site-packages\astroid-1.1.1-py3.4.egg\astroid\bases.py", line 115, in _infer_stmts
    for infered in stmt.infer(context):
  File "C:\Python34\lib\site-packages\astroid-1.1.1-py3.4.egg\astroid\bases.py", line 313, in wrapped
    for res in _func(node, context, **kwargs):
  File "C:\Python34\lib\site-packages\astroid-1.1.1-py3.4.egg\astroid\inference.py", line 358, in infer_ass
    stmts = list(self.assigned_stmts(context=context))
  File "C:\Python34\lib\site-packages\astroid-1.1.1-py3.4.egg\astroid\protocols.py", line 213, in assend_assigned_stmts
    return self.parent.assigned_stmts(self, context=context)
AttributeError: 'Starred' object has no attribute 'assigned_stmts'

TreeRebuilder3k' object has no attribute 'visit_nameconstant'

Originally reported by: Anonymous


Traceback (most recent call last):
File "C:\home\Programs\Python34\lib\site-packages\pylint-1.1.0-py3.4.egg\pylint\lint.py", line 672, in get_ast
return MANAGER.ast_from_file(filepath, modname, source=True)
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\manager.py", line 104, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\builder.py", line 127, in file_build
node = self.string_build(data, modname, path)
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\builder.py", line 133, in string_build
module = self._data_build(data, modname, path)
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\builder.py", line 157, in _data_build
module = rebuilder.visit_module(node, modname, package)
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 157, in visit_module
newnode.body = [self.visit(child, newnode) for child in node.body]
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 157, in
newnode.body = [self.visit(child, newnode) for child in node.body]
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 170, in visit
return self._transform(visit_method(node, parent))
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 500, in visit_function
newnode.body = [self.visit(child, newnode) for child in node.body]
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 500, in
newnode.body = [self.visit(child, newnode) for child in node.body]
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 170, in visit
return self._transform(visit_method(node, parent))
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 228, in visit_assign
newnode.value = self.visit(node.value, newnode)
File "C:\home\Programs\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\rebuilder.py", line 168, in visit
visit_method = getattr(self, visit_name)
AttributeError: 'TreeRebuilder3k' object has no attribute 'visit_nameconstant'
************* Module scratch
F0002:1:astroid-error: <class 'AttributeError'>: 'TreeRebuilder3k' object has no attribute 'visit_nameconstant'


Test errors with Python 3.4

Originally reported by: Arfrever Frehtes Taifersar Arahesis (BitBucket: arfrever, GitHub: @Arfrever?)


Test suite triggers exceptions with Python 3.4. I use Astroid 1.1.0.

========================  unittest_nodes.py  =========================
unhandled exception occurred while testing unittest_nodes
Traceback (most recent call last):
  File "/usr/lib64/python3.4/site-packages/logilab/common/pytest.py", line 429, in testfile
    options=self.options, outstream=sys.stderr)
  File "/usr/lib64/python3.4/site-packages/logilab/common/pytest.py", line 765, in __init__
    testLoader=NonStrictTestLoader())
  File "/usr/lib64/python3.4/unittest/main.py", line 63, in __init__
    self.module = __import__(module)
  File "/tmp/astroid-1.1.0/build/lib/astroid/test/unittest_nodes.py", line 28, in <module>
    from data import module as test_module
ImportError: cannot import name 'module'
=======================  unittest_builder.py  ========================
unhandled exception occurred while testing unittest_builder
Traceback (most recent call last):
  File "/usr/lib64/python3.4/site-packages/logilab/common/pytest.py", line 429, in testfile
    options=self.options, outstream=sys.stderr)
  File "/usr/lib64/python3.4/site-packages/logilab/common/pytest.py", line 765, in __init__
    testLoader=NonStrictTestLoader())
  File "/usr/lib64/python3.4/unittest/main.py", line 63, in __init__
    self.module = __import__(module)
  File "/tmp/astroid-1.1.0/build/lib/astroid/test/unittest_builder.py", line 38, in <module>
    from data import module as test_module
ImportError: cannot import name 'module'

py2gi: rewrite using the living object builder

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


The following is from Cole Robinson:

"""

I poked at this a bit. Basically just doing:

#!python

diff --git a/brain/py2gi.py b/brain/py2gi.py
index 5001b7c..2584055 100644
--- a/brain/py2gi.py
+++ b/brain/py2gi.py
@@ -128,18 +129,21 @@ def _new_import_module(self, modname, relative_only=False,
             modnames.append('gi._glib')
         elif modname == 'gi.repository.GObject':
             modnames.append('gi._gobject')
+
+        import importlib
+
+        astng = None
         try:
-            modcode = ''
-            for m in modnames:
-                __import__(m)
-                modcode += _gi_build_stub(sys.modules[m])
+            for m in modnames[:1]:
+                acmod = importlib.import_module(m)
+                astng = MANAGER.ast_from_module(acmod, modname=m)
         except ImportError:
             astng = _inspected_modules[modname] = None
         else:
-            astng = AstroidBuilder(MANAGER).string_build(modcode, modname)
             _inspected_modules[modname] = astng

It didn't blow up, but running it against a simple script like:

from gi.repository import Gtk

print Gtk.get_major_version
print Gtk.get_major_version()

w = Gtk.Label()
w.set_label("foo")

Yielded these errors:

*** Module pylint.testgtk E: 8, 0: Function 'wrapper' has no 'set_label' member (no-member) E: 8, 0: Instance of 'Label' has no 'set_label' member (no-member)

Unfortunately looking at the actual inspection code was overwhelming, so I don't think I can help here. I'm happy to test any work though, or help provide test cases.

"""


SyntaxError when examining gi modules containing identifiers not legal in python

Originally reported by: David Shea (BitBucket: davidshea, GitHub: @davidshea?)


For example, NetworkManager contains a class 80211ApFlags. Running pylint-1.1 on a file that contains

from gi.repository import NetworkManager

results in

Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 284, in getattr
return [self.import_module(name, relative_only=True)]
File "/usr/lib/python2.7/site-packages/astroid/brain/py2gi.py", line 139, in _new_import_module
astng = AstroidBuilder(MANAGER).string_build(modcode, modname)
File "/usr/lib/python2.7/site-packages/astroid/builder.py", line 133, in string_build
module = self._data_build(data, modname, path)
File "/usr/lib/python2.7/site-packages/astroid/builder.py", line 146, in _data_build
node = parse(data + '\n')
File "/usr/lib/python2.7/site-packages/astroid/builder.py", line 39, in parse
return compile(string, "", 'exec', PyCF_ONLY_AST)
File "", line 364
class 80211ApFlags(object):
^
SyntaxError: invalid syntax

The problem being that astroid attempts to generate python stubs for gi modules without checking whether the names are valid in python. Attaching a patch that fixes the problem by skipping such identifiers.


Support for sqlalchemy

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


Currently pylinting sqlalchemy code gives some false positives for E1120 (no-value-for-parameter)

I've attached sample code which exhibits this problem.

#!bash

$ pylint --version
pylint 1.1.0, 
astroid 1.0.1, common 0.61.0
Python 2.7.3 (default, Aug  9 2012, 17:23:57) 
[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)]

$ python -c "import sqlalchemy; print sqlalchemy.__version__"
0.9.4

$ pylint --reports=no sqlalchemy_testcase.py
************* Module sqlalchemy_testcase
E: 20, 4: No value passed for parameter 'dml' in function call (no-value-for-parameter)

The insert function is decorated, and the decorator fills in the 'dml' parameter. The callee providing it is an error.

I could potentially look at this myself but won't have the time to do so immediately.

Reported by Robbie Coomber on pylint-brain.


unittest_brain.HashlibTC.test_hashlib() fails with Python 3.2

Originally reported by: Arfrever Frehtes Taifersar Arahesis (BitBucket: arfrever, GitHub: @Arfrever?)


unittest_brain.HashlibTC.test_hashlib() fails with Python 3.2.

======================================================================
ERROR: test_hashlib (unittest_brain.HashlibTC)
Tests that brain extensions for hashlib work.
----------------------------------------------------------------------
...
  File "<string>", line 6
    return u''
             ^
SyntaxError: invalid syntax

I attach patch.


[PATCH] brain: pygi: Fix function inspection on newer pygobject

Originally reported by: Cole Robinson (BitBucket: crobinso, GitHub: @crobinso?)


Newer pyobject uses some local class FunctionInfo to export functions, and the pygi brain module doesn't handle it. So there's tons of no-member warnings

This patch alters the inspection to fallback to assuming anything 'callable' is a function, and everything left over is a constant. The latter bit fixes some issues I see using Gdk constants


Building astroid on Windows/Python3 fails

Originally reported by: Anonymous


  1. Create a script named "2to3.bat" (containing "python "%~dp0..\Tools\Scripts\2to3.py" %*") in PYTHONINSTALLDIR\Scripts, so that the setup.py provided with pylint actually works on Windows (that would be a bug too... but the Windows Python installer should take care of this in a perfect world)
  2. Unzip astroid-1.0.0.tar.gz, open a command window and change current working directory to astroid-1.0.0
  3. Type 'python setup.py build'
  4. Here is the result:

D:\Downloads\astroid-1.0.0>python setup.py build
running build
running build_py
creating build
creating build\lib
creating build\lib\astroid
copying .\as_string.py -> build\lib\astroid
copying .\bases.py -> build\lib\astroid
[...]
copying .\test\data\SSL1__init__.py -> build\lib\astroid\test\data\SSL1
creating build\lib\astroid\test\data2
copying .\test\data2\clientmodule_test.py -> build\lib\astroid\test\data2
copying .\test\data2\suppliermodule_test.py -> build\lib\astroid\test\data2
copying .\test\data2__init__.py -> build\lib\astroid\test\data2
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
package init file '.\test__init__.py' not found (or not a regular file)
running 2to3 on build\lib\astroid\brain
error: Le fichier spécifié est introuvable

For what it's worth, the 3 steps above work with logilab-common-0.60.0.tar.gz but not with astroid-1.0.0.tar.gz.


very long run time and/or stack overflow during inference

Originally reported by: Buck Evan (BitBucket: bukzor, GitHub: @bukzor?)


This simple script generates a (admittedly perverse) class which, when analyzed causes astroid to stack overflow.

http://paste.pound-python.org/show/HvGNK3BPWVkbqY1VAlyl/

If the number of methods is somewhat reduced, a huge running time is incurred instead, which is (for me) even worse. I'm trying to measure it, but currently it's ten minutes and counting.

Here is a trace of the inference being performed at the time of stack overflow:
http://paste.pound-python.org/show/QEm5Q15I1WMrHGnrWyqU/

This is a real issue for us as the cheetah templating framework generates code equivalent to the above. This causes pylint to be unusable to check these generated files. I do want to check these generated python files for issues, and pylint seems like the most full-featured tool available.


Install target modifies build directory.

Originally reported by: Edd Barrett (BitBucket: vext01, GitHub: @vext01?)


Hi,

I am in the process of updating pylint and dependencies in OpenBSD ports. I have ancountered a problem with astroid's install target.

In short, OpenBSD ports runs the build as a normal user, the install as root, and then removes the sources as the normal user. We package a ton of Python modules in this way.

The problem with astroid is, when setup.py install is run as root, it puts files owned by root in the build directory which then cannot be removed by the normal user. The install target should only copy files into the python library dirs and not modify the build directory.

You can reproduce this outside OpenBSD ports by making a virtualenv and running setup.py install as a root and then try to remove the source dir:

wilfred:tmp> rm -Rf astroid-1.1.1                                                                                                                                      
rm: astroid-1.1.1/build/lib/astroid/test/data2/clientmodule_test.py: Permission denied
rm: astroid-1.1.1/build/lib/astroid/test/data2/suppliermodule_test.py: Permission denied
rm: astroid-1.1.1/build/lib/astroid/test/data2/__init__.py: Permission denied
rm: astroid-1.1.1/build/lib/astroid/test/data2: Directory not empty
rm: astroid-1.1.1/build/lib/astroid/test/data/noendingnewline.py: Permission denied
rm: astroid-1.1.1/build/lib/astroid/test/data/absimport.py: Permission denied
rm: astroid-1.1.1/build/lib/astroid/test/data/SSL1/__init__.py: Permission denied
rm: astroid-1.1.1/build/lib/astroid/test/data/SSL1/Connection1.py: Permission denied
rm: astroid-1.1.1/build/lib/astroid/test/data/SSL1: Permission denied
...

Would appreciate a patch so I can continue updating pylint.

Cheers


Pylint throws an Exception when analyzing a file

Originally reported by: Gilles Devaux (BitBucket: gillesdevaux)


#!shell

************* Module kwarter.admin.util
C:  1, 0: Missing module docstring (missing-docstring)
Traceback (most recent call last):
  File "/Users/gillesdevaux/.virtualenvs/platform/bin/pylint", line 9, in <module>
    load_entry_point('pylint==1.0.0', 'console_scripts', 'pylint')()
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/__init__.py", line 21, in run_pylint
    Run(sys.argv[1:])
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/lint.py", line 1010, in __init__
    linter.check(args)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/lint.py", line 599, in check
    self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/lint.py", line 685, in check_astroid_module
    walker.walk(astroid)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/utils.py", line 662, in walk
    self.walk(child)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/utils.py", line 662, in walk
    self.walk(child)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/utils.py", line 662, in walk
    self.walk(child)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/utils.py", line 662, in walk
    self.walk(child)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/utils.py", line 662, in walk
    self.walk(child)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/utils.py", line 662, in walk
    self.walk(child)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/utils.py", line 659, in walk
    cb(astroid)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/pylint/checkers/typecheck.py", line 174, in visit_getattr
    if is_super(owner) or getattr(owner, 'type', None) == 'metaclass':
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/astroid/bases.py", line 51, in __getattr__
    return getattr(self._proxied, name)
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 681, in _class_type
    if _class_type(base, ancestors) != 'class':
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 680, in _class_type
    for base in klass.ancestors(recurs=False):
  File "/Users/gillesdevaux/.virtualenvs/platform/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 801, in ancestors
    for baseobj in stmt.infer(context):
TypeError: unbound method infer() must be called with Tuple instance as first argument (got InferenceContext instance instead)

I nailed it down to this code

#!python

def merge_url_qs(url, **kw):
    """ Merge the query string elements of a URL with the ones in ``kw``.
    If any query string element exists in ``url`` that also exists in
    ``kw``, replace it."""
    segments = urlparse.urlsplit(url)
    extra_qs = ['%s=%s' % (k, v) for (k, v) in
                urlparse.parse_qsl(segments.query, keep_blank_values=1)
                if k not in kw]
    qs = ''
    for k, v in sorted(kw.items()):
        qs += '%s=%s&' % (k, v)
    if extra_qs:
        qs += '&'.join(extra_qs)
    else:
        qs = qs[:-1]
    return urlparse.urlunsplit(
        (segments.scheme, segments.netloc, segments.path, qs, segments.fragment)
    )

Crash when inferring nodes from `with` statements

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


For Python 3, the following code will trigger a crash in astroid:

#!python

with open('c.txt', 'w') as stream, open('b.txt', 'w'):
    stream.write('a')

The traceback is:
File "D:\Python33\lib\site-packages\pylint-1.1.0-py3.3.egg\pylint\checkers\base.py", line 349, in visit_callfunc
infered = next(node.func.infer())
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\bases.py", line 307, in wrapped
for res in _func(node, context, *_kwargs):
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\bases.py", line 331, in wrapper
for node in func(_args, *_kwargs):
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\inference.py", line 208, in infer_getattr
for owner in self.expr.infer(context):
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\bases.py", line 307, in wrapped
for res in _func(node, context, *_kwargs):
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\bases.py", line 115, in _infer_stmts
for infered in stmt.infer(context):
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\bases.py", line 307, in wrapped
for res in _func(node, context, *_kwargs):
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\inference.py", line 353, in infer_ass
stmts = list(self.assigned_stmts(context=context))
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\bases.py", line 331, in wrapper
for node in func(_args, **kwargs):
File "D:\Python33\lib\site-packages\astroid-1.0.1-py3.3.egg\astroid\protocols.py", line 316, in with_assigned_stmts
for lst in vars.infer(context):
AttributeError: 'NoneType' object has no attribute 'infer'

The problem is in astroid.protocols.with_assignment_statements, where vars can be None in the case of the second context manager, which doesn't use the as assignment.


astroid gets stuck on classes which have themselves as a base

Originally reported by: David Shea (BitBucket: davidshea, GitHub: @davidshea?)


I don't really know how, but the TransactionSet class in rpm's python library has itself in the bases list, or something that looks like it:

import rpm
print(rpm.TransactionSet.bases)
(<type 'rpm.ts'>,)
print(rpm.ts)
<class 'rpm.transaction.TransactionSet'>

This causes _is_metaclass to get stuck recursing on the same class. Encountered when running pylint on code such as the following:

import rpm
ts = rpm.TransactionSet("/")
print ts.dbMatch("basenames", "/")

I don't know whether astroid's assessment of the class and its bases is correct, but on the assumption that it is I've attached a patch to avoid the infinite recursion.


failures for Python 3.4 beta

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


Most likely related to this change (adding NameConstant) http://hg.python.org/cpython/rev/03f92a9f0875 and relevant for this pull request: https://bitbucket.org/logilab/astroid/pull-request/16/add-support-for-ast-nameconstant/diff.

#!python

FAIL: test_argnames (__main__.FunctionNodeTC)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "unittest_scoped_nodes.py", line 333, in test_argnames
    self.assertEqual(astroid['f'].argnames(), ['a', 'b', 'c', 'args', 'kwargs'])
AssertionError: Lists differ: ['a', 'b', 'c', <_ast.arg object at 0x040FF5F0>, <_ast.ar[19 chars]6D0>] != ['a', 'b', 'c', 'args', 'kwargs']

First differing element 3:
<_ast.arg object at 0x040FF5F0>
args

+ ['a', 'b', 'c', 'args', 'kwargs']
- ['a',
-  'b',
-  'c',
-  <_ast.arg object at 0x040FF5F0>,
-  <_ast.arg object at 0x040FF6D0>]

======================================================================
FAIL: test_format_args (__main__.FunctionNodeTC)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "unittest_scoped_nodes.py", line 232, in test_format_args
    self.assertEqual(func.args.format_args(), 'any, base=data.module.YO, *args, **kwargs')
AssertionError: 'any,[18 chars]YO, *<_ast.arg object at 0x041057B0>, **<_ast.[21 chars]790>' != 'any,[18 chars]YO, *args, **kwargs'
- any, base=data.module.YO, *<_ast.arg object at 0x041057B0>, **<_ast.arg object at 0x04105790>
+ any, base=data.module.YO, *args, **kwargs

RuntimeError: maximum recursion depth exceeded

Originally reported by: BitBucket: DXist, GitHub: @DXist?


After update of astroid to 1.1.0 I get "maximum recursion depth exceeded". Reproduced on Python 2.7.5 and Python 2.7.6.

File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if _is_metaclass(baseobj):
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 678, in _is_metaclass
    for baseobj in base.infer():
File "/PYTHON2.7/site-packages/astroid/bases.py", line 313, in wrapped
    for res in _func(node, context, **kwargs):
File "/PYTHON2.7/site-packages/astroid/bases.py", line 337, in wrapper
    for node in func(*args, **kwargs):
File "/PYTHON2.7/site-packages/astroid/inference.py", line 213, in infer_getattr
    for owner in self.expr.infer(context):
File "/PYTHON2.7/site-packages/astroid/bases.py", line 313, in wrapped
    for res in _func(node, context, **kwargs):
File "/PYTHON2.7/site-packages/astroid/bases.py", line 337, in wrapper
    for node in func(*args, **kwargs):
File "/PYTHON2.7/site-packages/astroid/inference.py", line 213, in infer_getattr
    for owner in self.expr.infer(context):
File "/PYTHON2.7/site-packages/astroid/bases.py", line 313, in wrapped
    for res in _func(node, context, **kwargs):
File "/PYTHON2.7/site-packages/astroid/inference.py", line 146, in infer_name
    frame, stmts = self.lookup(self.name)
File "/PYTHON2.7/site-packages/astroid/node_classes.py", line 119, in lookup
    return self.scope().scope_lookup(self, name)
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 816, in scope_lookup
    return frame._scope_lookup(node, name, offset)
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 141, in _scope_lookup
    return pscope.scope_lookup(node, name)
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 273, in scope_lookup
    return self._scope_lookup(node, name, offset)
File "/PYTHON2.7/site-packages/astroid/scoped_nodes.py", line 130, in _scope_lookup
    stmts = node._filter_stmts(self.locals[name], self, offset)
File "/PYTHON2.7/site-packages/astroid/node_classes.py", line 146, in _filter_stmts
    myframe = self.frame()
File "/PYTHON2.7/site-packages/astroid/bases.py", line 443, in frame
    return self.parent.frame()
File "/PYTHON2.7/site-packages/astroid/bases.py", line 443, in frame
    return self.parent.frame()
File "/PYTHON2.7/site-packages/astroid/bases.py", line 443, in frame
    return self.parent.frame()
RuntimeError: maximum recursion depth exceeded

test_pylint_config_attr fails in version 1.2.0 under py3

Originally reported by: BitBucket: idella5


...S..F..
======================================================================
FAIL: test_pylint_config_attr (unittest_regrtest.NonRegressionTC)
----------------------------------------------------------------------
Traceback (most recent call last)
  File "/mnt/gen2/TmpDir/portage/dev-python/astroid-1.2.0/work/astroid-1.2.0-python3_4/build/lib/astroid/test/unittest_regrtest.py", line 116, in test_pylint_config_attr
    expect)
  File "/usr/lib64/python3.4/unittest/case.py", line 992, in assertListEqual
    self.assertSequenceEqual(list1, list2, msg, seq_type=list)
  File "/usr/lib64/python3.4/unittest/case.py", line 974, in assertSequenceEqual
    self.fail(msg)
  File "/usr/lib64/python3.4/unittest/case.py", line 639, in fail
    raise self.failureException(msg)
AssertionError: Lists differ: ['Opt[84 chars]enChecker', 'BaseChecker', 'OptionsProviderMixIn', 'ASTWalker'] != ['Opt[84 chars]enChecker', 'BaseChecker', 'OptionsProviderMixIn']

First list contains 1 additional elements.
First extra element 7:
ASTWalker

  ['OptionsManagerMixIn',
   'object',
   'MessagesHandlerMixIn',
   'ReportsHandlerMixIn',
   'BaseTokenChecker',
   'BaseChecker',
-  'OptionsProviderMixIn',
?                        ^

+  'OptionsProviderMixIn']
?                        ^

-  'ASTWalker']

                              no stdout                               
                              no stderr                               
======================================================================

Ran 343 test cases in 6.75s (6.75s CPU), 1 failures, 17 skipped
12 modules OK (1 failed)

Looks fairly straight forward. Last char a ',' in 1, ']" in the other.
ditto python3.3. Can you replicate? Do you require anything further?


pylint with astroid 1.2.0 fails with `StopIteration` exception

Originally reported by: Anonymous


Since upgrading to astroid 1.2.0 pylint has been failing with an exception. Minimal test case:

#!python

from nose.tools import raises

@raises(RuntimeError)
def test():
    pass

Run with pylint test.py gives traceback:

Traceback (most recent call last):
  File "/usr/local/bin/pylint", line 9, in <module>
    load_entry_point('pylint==1.3.0', 'console_scripts', 'pylint')()
  File "/usr/local/lib/python2.7/dist-packages/pylint/__init__.py", line 21, in run_pylint
    Run(sys.argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 991, in __init__
    linter.check(args)
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 585, in check
    self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
  File "/usr/local/lib/python2.7/dist-packages/pylint/lint.py", line 662, in check_astroid_module
    walker.walk(astroid)
  File "/usr/local/lib/python2.7/dist-packages/pylint/utils.py", line 804, in walk
    self.walk(child)
  File "/usr/local/lib/python2.7/dist-packages/pylint/utils.py", line 801, in walk
    cb(astroid)
  File "/usr/local/lib/python2.7/dist-packages/pylint/checkers/base.py", line 279, in visit_function
    self._check_redefinition(node.is_method() and 'method' or 'function', node)
  File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 670, in is_method
    return self.type != 'function' and isinstance(self.parent.frame(), Class)
  File "/usr/local/lib/python2.7/dist-packages/logilab/common/decorators.py", line 155, in __get__
    val = self.wrapped(inst)
  File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 536, in _function_type
    _type = _infer_decorator_callchain(node)
  File "/usr/local/lib/python2.7/dist-packages/astroid/scoped_nodes.py", line 501, in _infer_decorator_callchain
    result = current.infer_call_result(current.parent).next()
StopIteration

This test case works fine with astroid 1.1.0.


node.locals contains not precise data

Originally reported by: Michal Nowikowski (BitBucket: godfryd, GitHub: @godfryd?)


Not precise data can get into node.locals.
For example test code:

"""unused import"""
import xml.etree  # [unused-import]
import xml.sax  # [unused-import]

node.locals contains:

#!python
{'xml': [<Import() l.2 [functional.unused_import] at 0x7f18cde2ec10>, <Import() l.3 [functional.unused_import] at 0x7f18cde46090>]}

xml is not a local name. It cannot be referenced in code.
There is only available either xml.etree or xml.sax.

Wouldn't it be better to fix node.locals that it contains:

#!python
{'xml.etree': [<Import() l.2 [functional.unused_import] at 0x7f18cde2ec10>],
 'xml.sax': [<Import() l.3 [functional.unused_import] at 0x7f18cde46090>]}

This issue is related to issue pylint#293.


unittest_regrtest.NonRegressionTC.test_numpy_crash() fails

Originally reported by: Arfrever Frehtes Taifersar Arahesis (BitBucket: arfrever, GitHub: @Arfrever?)


unittest_regrtest.NonRegressionTC.test_numpy_crash() fails.
I use Astroid 1.0.1 and NumPy 1.8.0.

======================================================================
FAIL: test_numpy_crash (unittest_regrtest.NonRegressionTC)
test don't crash on numpy
----------------------------------------------------------------------
Traceback (most recent call last)
  File "/usr/lib64/python2.7/site-packages/logilab/common/testlib.py", line 661, in _proceed
    testfunc(*args, **kwargs)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'f_back', 'f_builtins', 'f_code', 'f_exc_traceback', 'f_exc_type', 'f_exc_value', 'f_globals', 'f_lasti', 'f_lineno', 'f_locals', 'f_restricted', 'f_trace'] == 'unittest_regrtest'

    ------------------------ local variables -------------------------
    args: ()
    kwargs: {}
    result: <logilab.common.testlib.SkipAwareTestResult run=4 errors=0 failures=0>
    self: <unittest_regrtest.NonRegressionTC testMethod=test_numpy_crash>
      self._TestCase__exc_info: <built-in function exc_info>
      self._TestCase__testMethodName: 'test_numpy_crash'
      self._cleanups: []
      self._current_test_descr: None
      self._options_: <Values at 0x1dde248: {'profile': None, 'skipped': None, 'tags_pattern': None, 'dbc': False, 'django': False, 'exitfirst': False, 'testdir': None, 'pdb': None, 'restart': False}>
      self._resultForDoCleanups: None
      self._testMethodDoc: "test don't crash on numpy"
      self._testMethodName: 'test_numpy_crash'
      self._type_equality_funcs: {<type 'dict'>: 'assertDictEqual', <type 'set'>: 'assertSetEqual', <type 'list'>: 'assertListEqual', <type 'frozenset'>: 'assertSetEqual', <type 'unicode'>: 'assertMultiLineEqual', <type 'tuple'>: 'assertTupleEqual'}
    testfunc: <bound method NonRegressionTC.test_numpy_crash of <unittest_regrtest.NonRegressionTC testMethod=test_numpy_crash>>
    ------------------------------------------------------------------

  File "/tmp/root/usr/lib64/python2.7/site-packages/astroid/test/unittest_regrtest.py", line 136, in test_numpy_crash
    self.assertIsInstance(infered[0], Instance)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'f_back', 'f_builtins', 'f_code', 'f_exc_traceback', 'f_exc_type', 'f_exc_value', 'f_globals', 'f_lasti', 'f_lineno', 'f_locals', 'f_restricted', 'f_trace'] == 'unittest_regrtest'

    ------------------------ local variables -------------------------
    astroid: <Module(unittest_regrtest) l.0 [unittest_regrtest] at Ox2d55dd0>
    builder: <astroid.builder.AstroidBuilder object at 0x2d55b10>
    callfunc: <Name(multiply) l.4 [unittest_regrtest] at Ox2d55f10>
    data: '\nfrom numpy import multiply\n\nmultiply(1, 2, 3)\n'
    infered: [YES]
    numpy: <module 'numpy' from '/usr/lib64/python2.7/site-packages/numpy/__init__.pyc'>
    self: <unittest_regrtest.NonRegressionTC testMethod=test_numpy_crash>
      self._TestCase__exc_info: <built-in function exc_info>
      self._TestCase__testMethodName: 'test_numpy_crash'
      self._cleanups: []
      self._current_test_descr: None
      self._options_: <Values at 0x1dde248: {'profile': None, 'skipped': None, 'tags_pattern': None, 'dbc': False, 'django': False, 'exitfirst': False, 'testdir': None, 'pdb': None, 'restart': False}>
      self._resultForDoCleanups: None
      self._testMethodDoc: "test don't crash on numpy"
      self._testMethodName: 'test_numpy_crash'
      self._type_equality_funcs: {<type 'dict'>: 'assertDictEqual', <type 'set'>: 'assertSetEqual', <type 'list'>: 'assertListEqual', <type 'frozenset'>: 'assertSetEqual', <type 'unicode'>: 'assertMultiLineEqual', <type 'tuple'>: 'assertTupleEqual'}
    ------------------------------------------------------------------

  File "/usr/lib64/python2.7/site-packages/logilab/common/testlib.py", line 1102, in assertIsInstance
    self.assertTrue(isinstance(obj, klass), msg)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'f_back', 'f_builtins', 'f_code', 'f_exc_traceback', 'f_exc_type', 'f_exc_value', 'f_globals', 'f_lasti', 'f_lineno', 'f_locals', 'f_restricted', 'f_trace'] == 'unittest_regrtest'

    ------------------------ local variables -------------------------
    klass: <class 'astroid.bases.Instance'>
    msg: "YES is not an instance of <class 'astroid.bases.Instance'> but of <class 'astroid.bases._Yes'>"
    obj: YES
    self: <unittest_regrtest.NonRegressionTC testMethod=test_numpy_crash>
      self._TestCase__exc_info: <built-in function exc_info>
      self._TestCase__testMethodName: 'test_numpy_crash'
      self._cleanups: []
      self._current_test_descr: None
      self._options_: <Values at 0x1dde248: {'profile': None, 'skipped': None, 'tags_pattern': None, 'dbc': False, 'django': False, 'exitfirst': False, 'testdir': None, 'pdb': None, 'restart': False}>
      self._resultForDoCleanups: None
      self._testMethodDoc: "test don't crash on numpy"
      self._testMethodName: 'test_numpy_crash'
      self._type_equality_funcs: {<type 'dict'>: 'assertDictEqual', <type 'set'>: 'assertSetEqual', <type 'list'>: 'assertListEqual', <type 'frozenset'>: 'assertSetEqual', <type 'unicode'>: 'assertMultiLineEqual', <type 'tuple'>: 'assertTupleEqual'}
    strict: False
    ------------------------------------------------------------------

  File "/usr/lib64/python2.7/unittest/case.py", line 424, in assertTrue
    raise self.failureException(msg)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'f_back', 'f_builtins', 'f_code', 'f_exc_traceback', 'f_exc_type', 'f_exc_value', 'f_globals', 'f_lasti', 'f_lineno', 'f_locals', 'f_restricted', 'f_trace'] == 'unittest_regrtest'

    ------------------------ local variables -------------------------
    expr: False
    msg: "YES is not an instance of <class 'astroid.bases.Instance'> but of <class 'astroid.bases._Yes'>"
    self: <unittest_regrtest.NonRegressionTC testMethod=test_numpy_crash>
      self._TestCase__exc_info: <built-in function exc_info>
      self._TestCase__testMethodName: 'test_numpy_crash'
      self._cleanups: []
      self._current_test_descr: None
      self._options_: <Values at 0x1dde248: {'profile': None, 'skipped': None, 'tags_pattern': None, 'dbc': False, 'django': False, 'exitfirst': False, 'testdir': None, 'pdb': None, 'restart': False}>
      self._resultForDoCleanups: None
      self._testMethodDoc: "test don't crash on numpy"
      self._testMethodName: 'test_numpy_crash'
      self._type_equality_funcs: {<type 'dict'>: 'assertDictEqual', <type 'set'>: 'assertSetEqual', <type 'list'>: 'assertListEqual', <type 'frozenset'>: 'assertSetEqual', <type 'unicode'>: 'assertMultiLineEqual', <type 'tuple'>: 'assertTupleEqual'}
    ------------------------------------------------------------------

AssertionError: YES is not an instance of <class 'astroid.bases.Instance'> but of <class 'astroid.bases._Yes'>

                              no stdout                               
                              no stderr                               

TypeError, due to definition of __call__ method through Proxy class

Originally reported by: BitBucket: dirkbaechle, GitHub: @dirkbaechle?


Hi there,

the attached script BuilderTests.py throws a TypeError

#!python

  TypeError: '_Yes' object is not iterable

when run through pylint (see attached issue.log for the full output), while the normal invocation with "python BuilderTests.py" shows the expected results.

Output of "pylint --version" is (installed from latest sources):

#!python

  No config file found, using default configuration
  pylint 1.1.0, 
  astroid 1.0.1, common 0.61.0
  Python 2.7.3 (default, Sep 26 2013, 20:03:06) 
  [GCC 4.6.3]

The given setup of classes and methods has a practical application, it's used in several unit tests for the build system SCons (www.scons.org).

Best regards,

Dirk


astroid doesn't understand descriptors very well

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


Given the following code, astroid detects A().descriptor as a bound method, while it's actually the result of calling A().descriptor(). It should be smarter about this and it should know that A.descriptor is a descriptor, not a function.

#!python

class lazy_attribute(object):
    def __init__(self, func):
        self._func = func
        self.__name__ = func.__name__
        self.__doc__ = func.__doc__

    def __get__(self, obj, klass=None):
        return self
        if obj is None:
            return None

        result = obj.__dict__[self.__name__] = self._func(obj)
        return result

    def __call__(self):
        return 400

class A:
   @lazy_attribute
   def descriptor(self):
        return 24

Astroid sometimes reports the wrong .tolineno for multiline Dicts, Lists, and Tuples

Originally reported by: David Jackson (BitBucket: ForSpareParts, GitHub: @ForSpareParts?)


If my source has:

#!python

MULTILINE_VARIABLE = [
    'foo',
    'bar',
    'baz'
]

I would expect tolineno to indicate the line containing the solitary ']' character. Instead, it indicates the line containing 'baz'. If I insert blank lines, a la:

#!python

MULTILINE_VARIABLE = [
    'foo',
    'bar',
    'baz'





]

I see the same behavior -- the 'baz' line is still the .tolineno.


pylint crash on PyQt4

Originally reported by: Okko Willeboordse (BitBucket: owillebo, GitHub: @owillebo?)


pylint-script.py 1.3.1,
astroid 1.2.1, common 0.62.1
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)]

Linting following script;

#!python

'''Show pylint issue.'''
import PyQt4.QtGui
import PyQt4.QtCore

class MyList(PyQt4.QtGui.QListWidget):
  '''MyList'''
  item = False
  @PyQt4.QtCore.pyqtSlot()
  def mySlot(self):
    '''mySlot'''
    self.item = True

gives;

#!python

>pylint.bat "gaiusbusgraphlegend.py" "--msg-template={path}:{line}:{column}: [{msg_id}] {msg}"
************* Module gaius.widgets.gaiusbusgraphlegend
gaiusbusgraphlegend.py:8:3: [E1101] Module 'PyQt4.QtCore' has no 'pyqtSlot' member
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\astroid\scoped_nodes.py", line 299, in getattr
    return [self.import_module(name, relative_only=True)]
  File "C:\Python27\lib\site-packages\astroid\brain\py2gi.py", line 125, in _new_import_module
    return _orig_import_module(self, modname, relative_only, level)
  File "C:\Python27\lib\site-packages\astroid\scoped_nodes.py", line 356, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "C:\Python27\lib\site-packages\astroid\manager.py", line 134, in ast_from_module_name
    return self.ast_from_module(module, modname)
  File "C:\Python27\lib\site-packages\astroid\manager.py", line 189, in ast_from_module
    return AstroidBuilder(self).module_build(module, modname)
  File "C:\Python27\lib\site-packages\astroid\builder.py", line 103, in module_build
    node = self.inspect_build(module, modname=modname, path=path)
  File "C:\Python27\lib\site-packages\astroid\raw_building.py", line 232, in inspect_build
    self.object_build(node, module)
  File "C:\Python27\lib\site-packages\astroid\raw_building.py", line 276, in object_build
    class_node = object_build_class(node, member, name)
  File "C:\Python27\lib\site-packages\astroid\raw_building.py", line 141, in object_build_class
    basenames = [base.__name__ for base in member.__bases__]
TypeError: C++ type 'QWidget*' is not supported as  type
>Exit code: 2    Time: 5.101

How can I write a plugin to change imports?

Originally reported by: Ethan Glasser-Camp (BitBucket: glasserc, GitHub: @glasserc?)


This is the same as pylint issue 95 (https://bitbucket.org/logilab/pylint/issue/95/how-can-i-write-a-plugin-to-change-imports). sthenault asked me to create this new issue specific to astroid and indicate that it is a follow-up.

Hi, I use flask. Flask defines a module called flask.ext. Importing flask.ext.foo is automagically mapped to importing flask_foo. I wrote a plugin on an old version of pylint to handle this: http://engineering.pave.com/post/51820567994/welcome-linting-flask-ext

I'm trying now to upgrade to pylint 1.0.0 and I see that the API has changed. I'm trying to use the new API but having trouble. I can define a transform function, as follows:

MANAGER.register_transform(node_classes.From, replace_from_flask_ext,
                           is_from_flask_ext)

With is_from_flask_ext and replace_from_flask_ext defined as:

def copy_node_info(src, dest):
    """Copy information from src to dest

    Every node in the AST has to have line number information.  Get
    the information from the old stmt."""
    for attr in ['lineno', 'fromlineno', 'tolineno',
                 'col_offset', 'parent']:
        if hasattr(src, attr):
            setattr(dest, attr, getattr(src, attr))


def splice(stmt, new_stmt):
    """Replace stmt with new_stmt in the AST

    Also, copy useful information from stmt to new_stmt.

    This assumes that stmt and new_stmt are of the same type and
    define the same names.
    """
    copy_node_info(stmt, new_stmt)

    # Replace stmt with new_stmt in the sequence of statements that
    # included stmt.
    # body = stmt.parent.body
    # i = body.index(stmt)
    # stmt.parent.body[i] = new_stmt

    # The names defined by an import statement are kept in stmt.names
    # as a pair of (exported_name, as_name). For example, "import foo,
    # bar as baz" corresponds to an import statement with
    # names=[("foo", None), ("bar", "baz")].
    #
    # All names that stmt defined should now be defined by new_stmt.
    for (name, as_name) in stmt.names:
        stmt.parent.set_local(as_name or name, new_stmt)

    return new_stmt

def is_from_flask_ext(node):
    """Is this a 'from flask.ext import wtf' statement?"""
    return node.modname == 'flask.ext'

def replace_from_flask_ext(node):
    """Replace 'from flask.ext import wtf' with 'import flask_wtf as wtf'."""
    new_stmt = node_classes.Import()
    new_stmt.names = []
    for pair in node.names:
        (name, as_name) = pair
        new_stmt.names.append(('flask_'+name, as_name or name))

    return splice(node, new_stmt)

I'm running it on code like (from the test):

from flask.ext import wtf

print wtf.Flboltolo
class MyForm(wtf.Form):
    """Test form"""
    field = StringField()

Unfortunately, this doesn't infer anything about the "wtf" variable. (In particular I don't see the "E: 15, 6: Module 'flask_wtf' has no 'Flboltolo' member" error.) I think this is due to the fact that the TreeRebuilder stores all From nodes in a member variable called _from_nodes, even when I replace them with other nodes. Commenting out self._from_nodes.append(newnode) on line 490 of rebuilder.py gives me the expected result. There appears to be no other way for me to achieve this effect, because the TreeRebuilder isn't passed to the transform functions and it cannot be accessed in any other way.


Problem with _io_discrepancy from astroid.raw_building for Python 3.4

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


Given the following:

#!python

import lxml.etree.ErrorDomains

Pylint fails (for Python 3.4) with the following:

#!python

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\scoped_nodes.py", line 284, in getattr
    return [self.import_module(name, relative_only=True)]
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\brain\py2gi.py", line 113, in _new_import_module
    return _orig_import_module(self, modname, relative_only, level)
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\scoped_nodes.py", line 339, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\manager.py", line 132, in ast_from_module_name
    return self.ast_from_module(module, modname)
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\manager.py", line 187, in ast_from_module
    return AstroidBuilder(self).module_build(module, modname)
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\builder.py", line 104, in module_build
    node = self.inspect_build(module, modname=modname, path=path)
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\raw_building.py", line 233, in inspect_build
    self.object_build(node, module)
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\raw_building.py", line 281, in object_build
    self.object_build(class_node, member)
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\raw_building.py", line 265, in object_build
    if (not _io_discrepancy(member) and
  File "C:\Python34\lib\site-packages\astroid-1.0.1-py3.4.egg\astroid\raw_building.py", line 45, in _io_discrepancy
    member_self.__name__ == '_io' and
AttributeError: 'dict' object has no attribute '__name__'

Spurious old-style class warnings for Python 3

Originally reported by: Antony Lee (BitBucket: anntzer, GitHub: @anntzer?)


With the current tip of astroid, pylint-python3 still warns about no-argument super() used on old-style classes, which is obviously wrong. I guess this can be fixed by changing the check in TreeRebuilder.visit_class (newnode._newstyle = metaclass in ('type', 'ABCMeta')) to include also the case sys.version_info > (3,).


wrong handling of metaclass/newstyle in rebuilder

Originally reported by: BitBucket: jcristau, GitHub: @jcristau?


On python 2, the rebuilder sets _newstyle to True on a class node if a metaclass variable is set in the parent namespace. This is wrong, per https://docs.python.org/2/reference/datamodel.html#customizing-class-creation only the global namespace matters.

Test case::

def test_metaclass_nested(self):
    astroid = abuilder.string_build(dedent("""
    class Test:
        __metaclass__ = type
        class Nested: pass
    """))
    nested = astroid['Test'].locals['Nested'][0]
    self.assertFalse(nested.newstyle)

Pylint crashes in astroid IndexError: list index out of range

Originally reported by: Anonymous


OS: Windows XP
Python 3.3.2
astroid 1.0.1
pylint 1.0.0

pylint --rcfile=pylint.ini src

Traceback (most recent call last):
File "C:\python33\lib\site-packages\astroid\scoped_nodes.py", line 284, in getattr
return [self.import_module(name, relative_only=True)]
File "C:\python33\lib\site-packages\astroid\brain\py2gi.py", line 113, in _new_import_module
return _orig_import_module(self, modname, relative_only, level)
File "C:\python33\lib\site-packages\astroid\scoped_nodes.py", line 339, in import_module
return MANAGER.ast_from_module_name(absmodname)
File "C:\python33\lib\site-packages\astroid\manager.py", line 133, in ast_from_module_name
return self.ast_from_file(filepath, modname, fallback=False)
File "C:\python33\lib\site-packages\astroid\manager.py", line 104, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "C:\python33\lib\site-packages\astroid\builder.py", line 127, in file_build
node = self.string_build(data, modname, path)
File "C:\python33\lib\site-packages\astroid\builder.py", line 140, in string_build
self.delayed_assattr(delayed)
File "C:\python33\lib\site-packages\astroid\builder.py", line 190, in delayed_assattr
for infered in node.expr.infer():
File "C:\python33\lib\site-packages\astroid\bases.py", line 311, in wrapped
for res in _func(node, context, *_kwargs):
File "C:\python33\lib\site-packages\astroid\bases.py", line 115, in _infer_stmts
for infered in stmt.infer(context):
File "C:\python33\lib\site-packages\astroid\bases.py", line 311, in wrapped
for res in _func(node, context, *_kwargs):
File "C:\python33\lib\site-packages\astroid\bases.py", line 115, in _infer_stmts
for infered in stmt.infer(context):
File "C:\python33\lib\site-packages\astroid\bases.py", line 311, in wrapped
for res in _func(node, context, *_kwargs):
File "C:\python33\lib\site-packages\astroid\bases.py", line 335, in wrapper
for node in func(_args, **kwargs):
File "C:\python33\lib\site-packages\astroid\inference.py", line 162, in infer_callfunc
for infered in callee.infer_call_result(self, callcontext):
File "C:\python33\lib\site-packages\astroid\bases.py", line 277, in infer_call_result
return self._proxied.infer_call_result(caller, context)
File "C:\python33\lib\site-packages\astroid\bases.py", line 261, in infer_call_result
return (x is YES and x or Instance(x) for x in caller.args[0].infer())
IndexError: list index out of range

Pylint continues:

Report
82 statements analysed.

Note that I have added diagnostics in 'bases.py', so the line number 261 may not be accurate:
260: print(caller,caller.args)
this prints: CallFunc() []
before the traceback


AttributeError: 'Module' object has no attribute '_type'

Originally reported by: Brian Lane (BitBucket: bcl, GitHub: @bcl?)


We have this bug report in Fedora - https://bugzilla.redhat.com/show_bug.cgi?id=1125259

It looks like the Method class is missing a _type attribute.

#!python

Version-Release number of selected component:
pylint-1.2-6.fc20

Additional info:
reporter:       libreport-2.2.3
cmdline:        /usr/bin/python /usr/bin/pylint '--msg-template={path}:{line}: [{msg_id}] {msg}' -r n scenarios/Apache.py --disable=C0103,W1201
dso_list:       python-astroid-1.1-3.fc20.noarch
executable:     /usr/bin/pylint
kernel:         3.14.4-200.fc20.x86_64
runlevel:       N 5
type:           Python
uid:            1000

Truncated backtrace:
scoped_nodes.py:686:_is_metaclass:AttributeError: 'Module' object has no attribute '_type'

Traceback (most recent call last):
  File "/usr/bin/pylint", line 9, in <module>
    load_entry_point('pylint==1.2.0', 'console_scripts', 'pylint')()
  File "/usr/lib/python2.7/site-packages/pylint/__init__.py", line 21, in run_pylint
    Run(sys.argv[1:])
  File "/usr/lib/python2.7/site-packages/pylint/lint.py", line 1047, in __init__
    linter.check(args)
  File "/usr/lib/python2.7/site-packages/pylint/lint.py", line 626, in check
    self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
  File "/usr/lib/python2.7/site-packages/pylint/lint.py", line 712, in check_astroid_module
    walker.walk(astroid)
  File "/usr/lib/python2.7/site-packages/pylint/utils.py", line 715, in walk
    self.walk(child)
  File "/usr/lib/python2.7/site-packages/pylint/utils.py", line 712, in walk
    cb(astroid)
  File "/usr/lib/python2.7/site-packages/pylint/checkers/classes.py", line 249, in visit_class
    if node.type == 'class':
  File "/usr/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 702, in _class_type
    if _is_metaclass(klass):
  File "/usr/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 686, in _is_metaclass
    if baseobj._type == 'metaclass':
AttributeError: 'Module' object has no attribute '_type'

Local variables in innermost frame:
baseobj: <Module(scenarios.GenericTest) l.0 [scenarios.GenericTest] at Ox139f710>
base: <Name(GenericTest) l.12 [scenarios.Apache] at Ox109d150>
klass: <Class(Apache) l.12 [scenarios.Apache] at Ox10a2350>

Installation broken under setuptools

Originally reported by: BitBucket: languitar, GitHub: @languitar?


With setuptools (not with pip) it is currently impossible to install astroid:

#!bash

jwienke@precise32:~$ easy_install --user --upgrade astroid
Searching for astroid
Reading http://pypi.python.org/simple/astroid/
Best match: astroid 1.0.0
Downloading https://pypi.python.org/packages/source/a/astroid/astroid-1.0.0.tar.gz#md5=e74430dfbbe09cd18ef75bd76f95425a
Processing astroid-1.0.0.tar.gz
Running astroid-1.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-uAX2Tf/astroid-1.0.0/egg-dist-tmp-KtVD7N
package init file './test/__init__.py' not found (or not a regular file)
package init file './test/__init__.py' not found (or not a regular file)
package init file './test/__init__.py' not found (or not a regular file)
Creating missing __init__.py for astroid.test
zip_safe flag not set; analyzing archive contents...
astroid.raw_building: module references __file__
astroid.raw_building: module references __path__
astroid.builder: module references __file__
astroid.manager: module references __file__
astroid.scoped_nodes: module references __file__
astroid.scoped_nodes: module references __path__
astroid.__init__: module references __file__
astroid.test.unittest_regrtest: module references __file__
astroid.test.unittest_lookup: module references __file__
astroid.test.unittest_lookup: module references __path__
astroid.test.unittest_builder: module references __file__
astroid.test.unittest_builder: module references __path__
astroid.test.unittest_inference: module references __file__
astroid.test.unittest_utils: module references __file__
astroid.test.unittest_nodes: module references __file__
astroid.test.unittest_scoped_nodes: module references __file__
astroid.test.unittest_scoped_nodes: module references __path__
astroid.test.unittest_inspector: module references __file__
astroid.test.unittest_manager: module references __file__
Adding astroid 1.0.0 to easy-install.pth file

Installed /home/jwienke/.local/lib/python2.7/site-packages/astroid-1.0.0-py2.7.egg
Processing dependencies for astroid
Searching for logilab-common>=0.60.0
Reading http://pypi.python.org/simple/logilab-common/
No local packages or download links found for logilab-common>=0.60.0
error: Could not find suitable distribution for Requirement.parse('logilab-common>=0.60.0')

builtin cache failure

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)


#!python

FAIL: test_builtin_lookup (unittest_lookup.LookupTC)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ubuntu/src/bitbucket.org/logilab/astroid/.tox/py33/lib/python3.3/site-packages/astroid/test/unittest_lookup.py", line 274, in test_builtin_lookup
    self.assertIs(intstmts[0], nodes.const_factory(1)._proxied)
AssertionError: <Class(int) l.None [builtins] at 0x7fd5e4222950> is not <Class(int) l.None [builtins] at 0x7fd5e5047cd0>


Error after upgrade to pylint 1.0

Originally reported by: Victor Safronovich (BitBucket: suvit, GitHub: @suvit?)


Traceback

#!python

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "</ws/env/local/lib/python2.7/site-packages/django/core/management/__init__.py",> line 443, in execute_from_command_line
    utility.execute()
  File "</ws/env/local/lib/python2.7/site-packages/django/core/management/__init__.py",> line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "</ws/env/local/lib/python2.7/site-packages/django/core/management/base.py",> line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "</ws/env/local/lib/python2.7/site-packages/django/core/management/base.py",> line 232, in execute
    output = self.handle(*args, **options)
  File "</ws/env/local/lib/python2.7/site-packages/django_jenkins/management/commands/__init__.py",> line 81, in handle
    if test_runner.run_tests(test_labels):
  File "</ws/env/local/lib/python2.7/site-packages/django/test/simple.py",> line 384, in run_tests
    self.teardown_test_environment()
  File "</ws/uralautomir/theme/tests.py",> line 67, in teardown_test_environment
    signals.teardown_test_environment.send(sender=self)
  File "</ws/env/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py",> line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "</ws/env/local/lib/python2.7/site-packages/django_jenkins/tasks/run_pylint.py",> line 43, in teardown_test_environment
    lint.Run(args, reporter=ParseableTextReporter(output=self.output), exit=False)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/lint.py",> line 1010, in __init__
    linter.check(args)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/lint.py",> line 599, in check
    self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/lint.py",> line 685, in check_astroid_module
    walker.walk(astroid)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/utils.py",> line 662, in walk
    self.walk(child)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/utils.py",> line 662, in walk
    self.walk(child)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/utils.py",> line 662, in walk
    self.walk(child)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/utils.py",> line 662, in walk
    self.walk(child)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/utils.py",> line 659, in walk
    cb(astroid)
  File "</ws/env/local/lib/python2.7/site-packages/pylint/checkers/typecheck.py",> line 174, in visit_getattr
    if is_super(owner) or getattr(owner, 'type', None) == 'metaclass':
  File "</ws/env/local/lib/python2.7/site-packages/astroid/bases.py",> line 51, in __getattr__
    return getattr(self._proxied, name)
  File "</ws/env/local/lib/python2.7/site-packages/astroid/scoped_nodes.py",> line 681, in _class_type
    if _class_type(base, ancestors) != 'class':
  File "</ws/env/local/lib/python2.7/site-packages/astroid/scoped_nodes.py",> line 680, in _class_type
    for base in klass.ancestors(recurs=False):
  File "</ws/env/local/lib/python2.7/site-packages/astroid/scoped_nodes.py",> line 801, in ancestors
    for baseobj in stmt.infer(context):
TypeError: unbound method infer() must be called with Tuple instance as first argument (got InferenceContext instance instead)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.