pylint-dev / pylint Goto Github PK
View Code? Open in Web Editor NEWIt's not just a linter that annoys you!
Home Page: https://pylint.readthedocs.io/en/latest/
License: GNU General Public License v2.0
It's not just a linter that annoys you!
Home Page: https://pylint.readthedocs.io/en/latest/
License: GNU General Public License v2.0
Originally reported by: Anonymous
Django ships handy 'service' attributes like _meta, _default_manager. They are considered as protected for client code but are often used in manager or queryset implementation.
Separate list of protected member names/regex'es to exclude from checking would be useful.
Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)
Hello!
The following bug bit me in a production environment and I was surprised that Pylint didn't warn me about it
After fiddling with checkers and astroid nodes, I've managed to pull off a small patch which reports this kind of problems. I took in account only tuple unpacking and handled only the assignments, so the patch could be small enough to be accepted. Also, I'm not a native english speaker and the wording in the patch can be improved.
Thank you for your time!
#!python
a, b = "something1", "something2", "something3" # fails
Originally reported by: Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?)
complains about missing delitem, setitem which don't make sense on (immutable) tuple
Originally reported by: Nikolaus Rath (BitBucket: nikratio, GitHub: @Nikratio?)
epylint currently starts pylint with stderr connected to a pipe. However, it never reads anything from the pipe. Therefore, if pylint generates enough output to saturate the internal buffer (which happens on larger stacktraces), epylint just hangs. In that case, epylint waits for pylint to terminate or write more data to stdout, but pylint hangs because it's waiting for someone to read from the stderr pipe.
I think the proper fix is to simply not connect stderr to a pipe, i.e. remove the stderr=PIPE argument to the Popen call.
Originally reported by: Chris Wong (BitBucket: wongc, GitHub: @wongc?)
pylint will always throw (at least under my environment) an exception when processing any python code with a finally block.
e.g.::
#!python
def main():
fp = None
try:
fp = open('/tmp/foo.dat')
data = fp.read()
print(data)
except OSError as exc:
print("Oops no file")
finally:
if fp:
fp.close()
if __name__ == '__main__':
main()
The backtrace::
#!
************* Module t2
C0111: 1,0: Missing docstring
C0111: 2,0:main: Missing docstring
C0103: 3,4:main: Invalid name "fp" for type variable (should match
[a-z_][a-z0-9_]{2,30}$)
Traceback (most recent call last):
File "/work/fwk-trunk/framework/lumberjack/virtualenv/bin/pylint", line 9, in <module>
load_entry_point('pylint==0.28.0', 'console_scripts', 'pylint')()
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/__init__.py", line 21, in run_pylint
Run(sys.argv[1:])
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/lint.py", line 995, in __init__
linter.check(args)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/lint.py", line 592, in check
self.check_astng_module(astng, walker, rawcheckers)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/lint.py", line 670, in check_astng_module
walker.walk(astng)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py", line 630, in walk
self.walk(child)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py", line 630, in walk
self.walk(child)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py", line 630, in walk
self.walk(child)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/utils.py", line 627, in walk
cb(astng)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/pylint/checkers/format.py", line 296, in visit_default
prev_sibl = node.previous_sibling()
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/logilab/astng/bases.py", line 592, in previous_sibling
stmts = self.parent.child_sequence(self)
File "/work/fwk-trunk/framework/lumberjack/virtualenv/lib/python3.3/site-packages/logilab/astng/bases.py", line 445, in child_sequence
raise ASTNGError(msg % (repr(child), repr(self)))
logilab.astng.exceptions.ASTNGError: Could not found <TryExcept() l.None [t2] at Ox7fa5c95c9f10> in <Function(main) l.2 [t2] at Ox7fa5c95c9c10>'s children
Originally reported by: Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?)
we would like to have modes which are a set of sections in the pylintrc file regrouping options overrides. A mode may be set using a command line option as well as in a specific file using inline instruction.
We may remove/deprecate -E option then.
Originally reported by: BitBucket: mitar, GitHub: @mitar?
It would be great if there would be a way to access docstrings and comments in their native context. For example, here are some checks I would like to do:
Originally reported by: Anthony Truchet (BitBucket: Anthony-Truchet)
The check_messages() annotation enables not executing visit_* or leave_* method in a checker if none of the are enabled.
We would like a similar feature at the checker level : it could be automatic (instrad of requiring annotations) as checkers list their messages.
Originally reported by: Anonymous
Hi all,
Got below error when ran Pylint 1.0 against one of my files.
I'm using Python 2.7.5 x86 Windows build.
File that causes this issue has 274 lines and looking at it I don't see anything highly unusual. Tried to remove each method from the file in turn and re-run Pylint, but it keeps crashing all the time. Also tried removing separate methods at once... no luck. Only removing the whole class from file (leaving only imports, log and nameduple definition) helped.
File contains a regular Python 2.x class deriving from object, defining class methods and generators (I'm using Twisted with it's defer.inlineCallbacks magic).
However, Pylint generally works on my other files using Twisted, I have no idea what's wrong with this one.
Any ideas?
My .pylintrc is attached.
#!python
Traceback (most recent call last):
File "C:\Python27\Scripts\pylint", line 5, in <module>
run_pylint()
File "C:\Python27\lib\site-packages\pylint\__init__.py", line 21, in run_pylint
Run(sys.argv[1:])
File "C:\Python27\lib\site-packages\pylint\lint.py", line 1010, in __init__
linter.check(args)
File "C:\Python27\lib\site-packages\pylint\lint.py", line 599, in check
self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
File "C:\Python27\lib\site-packages\pylint\lint.py", line 685, in check_astroid_module
walker.walk(astroid)
File "C:\Python27\lib\site-packages\pylint\utils.py", line 662, in walk
self.walk(child)
File "C:\Python27\lib\site-packages\pylint\utils.py", line 662, in walk
self.walk(child)
File "C:\Python27\lib\site-packages\pylint\utils.py", line 662, in walk
self.walk(child)
File "C:\Python27\lib\site-packages\pylint\utils.py", line 662, in walk
self.walk(child)
File "C:\Python27\lib\site-packages\pylint\utils.py", line 662, in walk
self.walk(child)
File "C:\Python27\lib\site-packages\pylint\utils.py", line 662, in walk
self.walk(child)
File "C:\Python27\lib\site-packages\pylint\utils.py", line 659, in walk
cb(astroid)
File "C:\Python27\lib\site-packages\pylint\checkers\typecheck.py", line 174, in visit_getattr
if is_super(owner) or getattr(owner, 'type', None) == 'metaclass':
File "C:\Python27\lib\site-packages\astroid\bases.py", line 51, in __getattr__
return getattr(self._proxied, name)
File "C:\Python27\lib\site-packages\astroid\scoped_nodes.py", line 680, in _class_type
for base in klass.ancestors(recurs=False):
File "C:\Python27\lib\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)
Originally reported by: Jorge Araya Navarro (BitBucket: shackra, GitHub: @shackra?)
I'm not sure what's happening...
#!bash
jorge [~/coders/desarrollo/thomas-aquinas] ~> pyreverse -c cocos2d -a 1 -s 1 -f ALL -o png summa/
parsing summa/__init__.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/utils.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/__init__.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/framegrabber.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/summanode.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/collision_model.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/text.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/menu.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/particle.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/batch.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/director.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/shader.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/wired.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/rect.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/skeleton.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/gl_framebuffer_object.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/camera.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/draw.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/tiles.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/custom_clocks.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/path.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/sprite.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/grid.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/particle_systems.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/scene.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/euclid.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/scenes/__init__.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/scenes/transitions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/scenes/pause.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/__init__.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/instant_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/base_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/grid3d_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/camera_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/tiledgrid_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/move_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/basegrid_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/interval_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/actions/quadmoveby_actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/__init__.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/music.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/vector.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/system.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/objectbase.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/sftime.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/libs.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/soundstatus.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/actions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/sfmusic.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/effect.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/listener.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/audio/exceptions.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/layer/__init__.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/layer/base_layers.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/layer/util_layers.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/layer/python_interpreter.py...
parsing /home/jorge/coders/desarrollo/thomas-aquinas/summa/layer/scrolling.py...
Traceback (most recent call last):
File "/usr/bin/pyreverse", line 9, in <module>
load_entry_point('pylint==0.28.0', 'console_scripts', 'pyreverse')()
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/__init__.py", line 39, in run_pyreverse
Run(sys.argv[1:])
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/main.py", line 98, in __init__
sys.exit(self.run(args))
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/main.py", line 112, in run
diadefs = handler.get_diadefs(project, linker)
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/diadefslib.py", line 226, in get_diadefs
diagrams.append(generator.class_diagram(project, klass))
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/diadefslib.py", line 194, in class_diagram
module, klass = klass.rsplit('.', 1)
ValueError: need more than 1 value to unpack
jorge [~/coders/desarrollo/thomas-aquinas] ~>
Then I tried to parse that file directly to see what happen, and I got this:
#!bash
jorge [~/coders/desarrollo/thomas-aquinas] ~> pyreverse -c cocos2d -a 1 -s 1 -f ALL -o png summa/layer/scrolling.py
parsing summa/layer/scrolling.py...
Traceback (most recent call last):
File "/usr/bin/pyreverse", line 9, in <module>
load_entry_point('pylint==0.28.0', 'console_scripts', 'pyreverse')()
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/__init__.py", line 39, in run_pyreverse
Run(sys.argv[1:])
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/main.py", line 98, in __init__
sys.exit(self.run(args))
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/main.py", line 112, in run
diadefs = handler.get_diadefs(project, linker)
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/diadefslib.py", line 226, in get_diadefs
diagrams.append(generator.class_diagram(project, klass))
File "/usr/lib/python2.7/site-packages/pylint-0.28.0-py2.7.egg/pylint/pyreverse/diadefslib.py", line 199, in class_diagram
klass = module.ilookup(klass).next()
File "/usr/lib/python2.7/site-packages/logilab_astng-0.24.3-py2.7.egg/logilab/astng/bases.py", line 124, in _infer_stmts
raise InferenceError(str(stmt))
logilab.astng.exceptions.InferenceError: None
jorge [~/coders/desarrollo/thomas-aquinas] ~>
The file is right here shackra/thomas-aquinas/src/summa/layer/scrolling.py...
Originally reported by: George Sakkis (BitBucket: gsakkis, GitHub: @gsakkis?)
Running smoketest.py gives 7 failures on the current tip (f56b411):
$ python test/smoketest.py
.FFFFF...F..F.
======================================================================
FAIL: test1 (__main__.RunTC)
make pylint checking itself
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/smoketest.py", line 58, in test1
self._runtest(['--include-ids=y', 'pylint.lint'], reporter=TextReporter(StringIO()))
File "test/smoketest.py", line 42, in _runtest
self.assertEqual(ex.code, code)
AssertionError: 4 != 28
======================================================================
FAIL: test2 (__main__.RunTC)
make pylint checking itself
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/smoketest.py", line 63, in test2
self._runtest(['pylint.lint'], reporter=ParseableTextReporter(StringIO()))
File "test/smoketest.py", line 42, in _runtest
self.assertEqual(ex.code, code)
AssertionError: 4 != 28
======================================================================
FAIL: test3 (__main__.RunTC)
make pylint checking itself
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/smoketest.py", line 68, in test3
self._runtest(['pylint.lint'], reporter=HTMLReporter(StringIO()))
File "test/smoketest.py", line 42, in _runtest
self.assertEqual(ex.code, code)
AssertionError: 4 != 28
======================================================================
FAIL: test4 (__main__.RunTC)
make pylint checking itself
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/smoketest.py", line 73, in test4
self._runtest(['pylint.lint'], reporter=ColorizedTextReporter(StringIO()))
File "test/smoketest.py", line 42, in _runtest
self.assertEqual(ex.code, code)
AssertionError: 4 != 28
======================================================================
FAIL: test5 (__main__.RunTC)
make pylint checking itself
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/smoketest.py", line 78, in test5
self._runtest(['pylint.lint'], reporter=VSTextReporter(StringIO()))
File "test/smoketest.py", line 42, in _runtest
self.assertEqual(ex.code, code)
AssertionError: 4 != 28
======================================================================
FAIL: test_generated_members (__main__.RunTC)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/smoketest.py", line 87, in test_generated_members
self._runtest(['--generated-members=objects,DoesNotExist,delay,retry,"[a-zA-Z]+_set{1,2}""', 'pylint.lint'])
File "test/smoketest.py", line 42, in _runtest
self.assertEqual(ex.code, code)
AssertionError: 4 != 28
======================================================================
FAIL: test_no_out_encoding (__main__.RunTC)
test redirection of stdout with non ascii caracters
----------------------------------------------------------------------
Traceback (most recent call last):
File "test/smoketest.py", line 128, in test_no_out_encoding
out=strio)
File "test/smoketest.py", line 42, in _runtest
self.assertEqual(ex.code, code)
AssertionError: 20 != 28
----------------------------------------------------------------------
Ran 14 tests in 6.010s
FAILED (failures=7)
Originally reported by: Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?)
also, state in the documentation that symbolic ids are the way to go now
Originally reported by: Chris Wong (BitBucket: wongc, GitHub: @wongc?)
Given files: t.py, tmp/u.py and tmp/v.py (and of course an empty tmp/init.py)
t.py
#!python
import tmp.u
tmp.u.obfuscate()
tmp/u.py
#!python
from .v import *
tmp/v.py
#!python
def obfuscate():
print("hello world")
I will always get a E1101 error under Python 3.3 for t.py
#!
************* Module t
C0111: 1,0: Missing docstring
E1101: 4,0: Module 'tmp.u' has no 'obfuscate' member
This works fine using Pylint under 2.6.
Originally reported by: BitBucket: jan_samohyl
Running epylint on Python 3.2 fails with:
Traceback (most recent call last):
File "/usr/local/bin/epylint", line 3, in
epylint.Run()
File "/usr/local/lib/python3.2/dist-packages/pylint/epylint.py", line 161, in Run
sys.exit(lint(sys.argv[1]))
File "/usr/local/lib/python3.2/dist-packages/pylint/epylint.py", line 96, in lint
if line.startswith("No config file found"):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
I am attaching a small fix that seems to work for me.
Originally reported by: BitBucket: dotpot, GitHub: @dotpot?
It's all started after 1.0.0 release (0.28.0 now is not working as well (as it was working before 1.0.0 release), might be some dependant libs change on pylint end).
So pylint fails due to IOError and "missing" imports, BUT nosetests (running in the same environment) passes everything (in tests, classes using scipy are tested as well - so imports exists and everything is fine).
Here is traceback:
#!bash
$ pylint --rcfile=pylintrc ./ourProject
Traceback (most recent call last):
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 284, in getattr
return [self.import_module(name, relative_only=True)]
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 339, in import_module
return MANAGER.ast_from_module_name(absmodname)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/manager.py", line 121, in ast_from_module_name
filepath = self.file_from_module_name(modname, context_file)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/manager.py", line 165, in file_from_module_name
context_file=contextfile)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/logilab/common/modutils.py", line 295, in file_from_modpath
return _file_from_modpath(modpath, path, context)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/logilab/common/modutils.py", line 554, in _file_from_modpath
mtype, mp_filename = _module_file(modpath, path)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/logilab/common/modutils.py", line 659, in _module_file
data = open(join(mp_filename, '__init__.py')).read(4096)
IOError: [Errno 2] No such file or directory: '/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/scipy/__init__.py'
************* Module ourProject.xx.xx.xxx
E: 7, 0: No name 'cluster' in module 'scipy' (no-name-in-module)
Traceback (most recent call last):
File "/home/travis/virtualenv/python2.7/bin/pylint", line 9, in <module>
load_entry_point('pylint==1.0.0', 'console_scripts', 'pylint')()
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/__init__.py", line 21, in run_pylint
Run(sys.argv[1:])
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/lint.py", line 1010, in __init__
linter.check(args)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/lint.py", line 599, in check
self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/lint.py", line 685, in check_astroid_module
walker.walk(astroid)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/utils.py", line 662, in walk
self.walk(child)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/utils.py", line 659, in walk
cb(astroid)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/checkers/imports.py", line 228, in visit_import
importedmodnode = self.get_imported_module(modnode, node, name)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/pylint/checkers/imports.py", line 266, in get_imported_module
return importnode.do_import_module(modname)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/mixins.py", line 103, in do_import_module
return mymodule.import_module(modname, level=level)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/scoped_nodes.py", line 345, in import_module
return MANAGER.ast_from_module_name(modname)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/manager.py", line 121, in ast_from_module_name
filepath = self.file_from_module_name(modname, context_file)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/astroid/manager.py", line 165, in file_from_module_name
context_file=contextfile)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/logilab/common/modutils.py", line 295, in file_from_modpath
return _file_from_modpath(modpath, path, context)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/logilab/common/modutils.py", line 554, in _file_from_modpath
mtype, mp_filename = _module_file(modpath, path)
File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/logilab/common/modutils.py", line 659, in _module_file
data = open(join(mp_filename, '__init__.py')).read(4096)
IOError: [Errno 2] No such file or directory: '/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/scipy/__init__.py'
Any ideas? Solutions?
Originally reported by: Chris Rebert (BitBucket: cvrebert, GitHub: @cvrebert?)
Testcase:
#!python
# example.py
x = []
try:
x[42]
except IndexError as err:
err.message.find("out of range")
Somehow "message" ends up being treated as a class and the inaccurate warning gets repeated 5 times for some reason:
#!bash
$ pylint --include-ids=y --report=n example.py
No config file found, using default configuration
************* Module example
C0111: 1,0: Missing docstring
C0103: 1,0: Invalid name "x" for type constant (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
E1101: 6,4: Class 'message' has no 'find' member
E1101: 6,4: Class 'message' has no 'find' member
E1101: 6,4: Class 'message' has no 'find' member
E1101: 6,4: Class 'message' has no 'find' member
E1101: 6,4: Class 'message' has no 'find' member
$ pylint --version
No config file found, using default configuration
pylint 0.28.0,
astng 0.24.3, common 0.59.1
Python 2.7.5 (default, May 21 2013, 11:38:15)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))]
Originally reported by: Andrew Carman (BitBucket: carmandrew, GitHub: @carmandrew?)
When you run pylint on the following file, it reports no errors, but there is very clearly an error when running (AttributeError: 'module' object has no attribute 'saxutils').
import xml.sax.handler
print(xml.sax.handler)
print(xml.sax.saxutils)
Originally reported by: BitBucket: mitar, GitHub: @mitar?
I have the following code:
#!python
def custom_decorator(platform=None, order=50):
def wrapper(f):
f.cgm_module = True
f.cgm_module_order = order
f.cgm_module_platform = platform
return staticmethod(f)
return wrapper
class SomeClass(object):
@custom_decorator()
def network(node, cfg):
pass
And pylint complains that "Method should have "self" as first argument". But as this is a static method decorator in fact it should not need a "self" as first argument.
pylint 0.28.0,
astng 0.24.3, common 0.59.1
Originally reported by: Pierre-Yves David (BitBucket: marmoute, GitHub: @marmoute?)
Trackback while running pylint on hgview
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/apycotlib/atest.py", line 281, in run_checker
status = checker.check(self)
File "/usr/lib/python2.6/dist-packages/apycotlib/checkers/__init__.py", line 27, in check
self.set_status(self.do_check(test))
File "/usr/lib/python2.6/dist-packages/apycotlib/checkers/python.py", line 505, in do_check
linter.check(pyinstall_path(test))
File "/usr/lib/pymodules/python2.6/pylint/lint.py", line 588, in check
self._add_suppression_messages()
File "/usr/lib/pymodules/python2.6/pylint/lint.py", line 711, in _add_suppression_messages
for (warning, from_), lines in self._ignored_msgs.iteritems():
RuntimeError: dictionary changed size during iteration
You can see the details here: http://www.logilab.org/testexecution/129510?tab=pylint
Originally reported by: Mihai C. (BitBucket: mihaic, GitHub: @mihaic?)
Please include the "main" function in NO_REQUIRED_DOC_RGX. The official Python documentation references its idiomatic usage:
http://docs.python.org/2/library/__main__.html
Originally reported by: Gabi Davar (BitBucket: grizzlynyo)
The manual was converted to sphinx but the manifest.in was not updated.
Originally reported by: George Sakkis (BitBucket: gsakkis, GitHub: @gsakkis?)
pip install -e hg+ssh://[email protected]/logilab/pylint#egg=pylint
...
Downloading/unpacking astroid>=0.24.3 (from pylint)
Could not find any downloads that satisfy the requirement astroid>=0.24.3 (from pylint)
No distributions at all found for astroid>=0.24.3 (from pylint)
pip install -e hg+http://hg.logilab.org/pylint#egg=pylint
python -c "import pylint"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pylint
The problem is that the package contents are copied directly under $VIRTUALENV/src/pylint/ instead of making a package
under it (i.e., .virtualenv/src/pylint/pylint).
Originally reported by: Andrew Pennebaker (BitBucket: mcandre, GitHub: @mcandre?)
You know your old Python code is bad when pylint rates it at -1.73/10.
https://github.com/mcandre/mcandre/tree/master/python/SuDokuSolver
Originally reported by: Anonymous
The import of the string module triggers a w0402 "deprecated module".
But only most of the functions are deprecated, most of the constants therein are still valid and "unique".
Could the warning made only upon the call of the relevant functions?
Originally reported by: BitBucket: Jajcus, GitHub: @Jajcus?
Test Python 3 code (test.py):
:::python
class Base(object):
def __init__(self):
super().__init__()
Running 'pylint --include-ids=y --reports=n --disable=C0111,R0903 test' (using Python3 pylint) gives:
E1003: 2,4:Base.__init__: Bad first argument %r given to super class
There are three problems with that:
Originally reported by: BitBucket: udifuchs
The following code:
#!python
class Foo(object):
def __init__(self):
self._bar = 3
@property
def bar(self):
return self._bar
@bar.setter
def bar(self, value):
self._bar = value
class Foo2(Foo):
@bar.setter
def bar(self, value):
self._bar = value * 2
Results in the warning:
W0221: 15,4:Foo2.bar: Arguments number differs from overridden method
#!sh
$ pylint --version
pylint 0.26.0,
astng 0.24.1, common 0.58.3
Python 2.7.4 (default, Apr 19 2013, 18:28:01)
[GCC 4.7.3]
Originally reported by: Nikolaus Rath (BitBucket: nikratio, GitHub: @Nikratio?)
Testcase:
#!
[22] nikratio@vostro:~/tmp$ ls mypackage/
module1.py
[0] nikratio@vostro:~/tmp$ cat mypackage/module1.py
from .logging import logging
[0] nikratio@vostro:~/tmp$ pylint mypackage/module1.py
************* Module module1
C0111: 1,0: Missing docstring
Traceback (most recent call last):
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_astng-0.24.3-py3.3.egg/logilab/astng/manager.py", line 161, in file_from_module_name
value = self._mod_file_cache[(modname, contextfile)]
KeyError: ('logging.logging', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_astng-0.24.3-py3.3.egg/logilab/astng/scoped_nodes.py", line 284, in getattr
return [self.import_module(name, relative_only=True)]
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_astng-0.24.3-py3.3.egg/logilab/astng/scoped_nodes.py", line 339, in import_module
return MANAGER.astng_from_module_name(absmodname)
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_astng-0.24.3-py3.3.egg/logilab/astng/manager.py", line 121, in astng_from_module_name
filepath = self.file_from_module_name(modname, context_file)
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_astng-0.24.3-py3.3.egg/logilab/astng/manager.py", line 165, in file_from_module_name
context_file=contextfile)
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_common-0.59.1-py3.3.egg/logilab/common/modutils.py", line 295, in file_from_modpath
return _file_from_modpath(modpath, path, context)
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_common-0.59.1-py3.3.egg/logilab/common/modutils.py", line 554, in _file_from_modpath
mtype, mp_filename = _module_file(modpath, path)
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_common-0.59.1-py3.3.egg/logilab/common/modutils.py", line 620, in _module_file
emtype, emp_filename, zippath = _search_zip(modpath, pic)
File "/home/nikratio/.local/lib/python3.3/site-packages/logilab_common-0.59.1-py3.3.egg/logilab/common/modutils.py", line 573, in _search_zip
'.'.join(modpath[1:]), file, modpath))
NameError: global name 'file' is not defined
E0611: 1,0: No name 'logging' in module 'logging'
W0611: 1,0: Unused import logging
[22] nikratio@vostro:~/tmp$
Originally reported by: Benjamin Arbogast (BitBucket: Koblaid, GitHub: @Koblaid?)
I ran pyreverse with twisted: /usr/lib/python2.7/dist-packages$ pyreverse -o png twisted/
.
Some files are parsed but it seems to get stuck on parsing /usr/lib/python2.7/dist-packages/twisted/spread/ui/tktree.py...
.
I use python 2.7.3 with twisted 12.2.0-1 (unchanged Ubuntu package).
Originally reported by: Anonymous
According to http://docs.pylint.org/installation.html#dependencies, "It should be compatible with any Python version >= 2.5".
In practice, it does not seem to work with 2.5. I get errors such as:
/home/travis/virtualenv/python2.5/lib/python2.5/site-packages/pylint/checkers/utils.py:402: Warning: 'as' will become a reserved keyword in Python 2.6
File "/home/travis/virtualenv/python2.5/lib/python2.5/site-packages/pylint/checkers/utils.py", line 402
except IndexError as error:
^
SyntaxError: invalid syntax
It seems very few places use the "as" keyword. Can Python 2.5 backward compatibility be put back (it used to work a few weeks ago)?
Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)
There's a small bug in 1004:8c0cdbac4de2, in utils.py/register_plugins: os.isdir is used instead of os.path.isdir.
Originally reported by: Sylvain Thénault (BitBucket: sthenault, GitHub: @sthenault?)
this is probably rather a pylint-brain or astroid issue as it should be done using the new transformation API.
Originally reported by: BitBucket: Juanlu001, GitHub: @Juanlu001?
Version 1.0 was released last week, but online docs still refer to v0.27 (not even v0.28).
Originally reported by: BitBucket: trampgeek, GitHub: @trampgeek?
Using pylint 0.28.0/astng 0.24.3/common 0.59.1 with Python 3.3 under RHEL fails with
Traceback (most recent call last):
File "/usr/lib/python3.3/site-packages/logilab/astng/manager.py", line 161, in file_from_module_name
value = self._mod_file_cache[(modname, contextfile)]
KeyError: ('posix', None)
when processing some imports, e.g. posix. The following test file is an example that triggers the above error (but it can occur indirectly, without a direct import of posix).
import posix
'''Comment'''
def sqr(n):
'''Function comment'''
return n * n
print(sqr(-9))
A fix (or probably hack) that seems to be working for me is to change line 624 of logilab/common/modutils.py from
... except ValueError:
to
... except (AttributeError, ValueError):
This ensures that the AttributeError that's raised (see full traceback attached) is treated as just another failure.
Originally reported by: Jace Browning (BitBucket: jacebrowning, GitHub: @jacebrowning?)
For the following code:
#!python
from pkg_resources import get_distribution
print(get_distribution('setuptools').version)
I get:
#!bash
E1103: 2,6: Instance of 'str' has no 'version' member (but some types could not be inferred)
Expected:
No warning should occur because the return value of get_distribution
does, in fact, have a version
member.
Version:
#!bash
pylint 0.28.0,
astng 0.24.3, common 0.59.1
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
Originally reported by: George Sakkis (BitBucket: gsakkis, GitHub: @gsakkis?)
Running the pylint tip on the following snippet raises "TypeError: unbound method infer() must be called with Tuple instance as first argument (got InferenceContext instance instead)":
from urlparse import urlparse
def get_scheme(full_url):
return urlparse(full_url).scheme
Originally reported by: BitBucket: Jajcus, GitHub: @Jajcus?
Python 3 test code:
:::python
from django import forms
from .models import MyModel
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
fields = ("test",)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Pylint 0.25.1 generates:
E1002 'Use of super on an old style class' message which is wrong, because:
The problem is also discussed on StackOverflow: http://stackoverflow.com/questions/15257534/django-forms-modelform-pylint-and-new-old-style-classes
Originally reported by: Julian O (BitBucket: oddthinking, GitHub: @oddthinking?)
Chapter 2 (Built-in Functions) of the Python Standard Library documentation (at least in Python 2.7.2) states:
When opening a file, it’s preferable to use open() instead of invoking the file constructor directly.
e.g. the following code is preferred:
with open("filename", "rb") as source_file:
to this:
with file("filename", "rb") as source_file:
I have no idea of the rationale of this rule, but I do know I have been violating it consistently!
To help people like me, please consider adding a new warning code for when the file constructor is used directly.
(I guess it should not trigger if in the init method of a subclass of file, but that might be rare enough to ignore.)
Originally reported by: BitBucket: mitar, GitHub: @mitar?
I have the following code:
#!python
class DisplayComponent(components.FrontendComponent):
@classmethod
def get_urls(cls):
return super(DisplayComponent, cls).get_urls()
And pylint complains that "No value passed for parameter 'cls' in function call". Which is of course wrong as this is done automatically.
pylint 0.28.0,
astng 0.24.3, common 0.59.1
Originally reported by: Andrew Carman (BitBucket: carmandrew, GitHub: @carmandrew?)
Pylint should issue a warning when you use a variable that's defined inside an if statement.
#!python
if False:
foo = 7
print foo
This has no pylint errors, but raises an exception when run.
Originally reported by: BitBucket: vmalloc, GitHub: @vmalloc?
See https://travis-ci.org/vmalloc/shakedown/jobs/6903251 for an example
Originally reported by: Andrew Pennebaker (BitBucket: mcandre, GitHub: @mcandre?)
Most linters offer CLI syntax of linter
meaning lint all relevant files in a directory. Typically, users run linter ., to lint the current directory.pylint rejects this for directories with no init.py, such as collections of standalone, one-off scripts. As a mitigation, we can use pylint *.py, but it would be nice to type pylint ., in keeping with conventional linter syntax.
Originally reported by: BitBucket: idella5
I've repeated this many times and I still get these numerous errors fails.
======================= test_import_graph.py =======================
.E
======================================================================
ERROR: test_checker_dep_graphs (test_import_graph.ImportCheckerTC)
----------------------------------------------------------------------
Traceback (most recent call last)
*******************************************************************************
Ran 885 test cases in 27.11s (26.98s CPU), 15 errors, 4 failures, 3 skipped
7 modules OK (4 failed)
Far too many to list. sample of Error types;
TypeError: coercing to Unicode: need string or buffer, NoneType found
AttributeError: 'Function' object has no attribute 'ancestors'
AttributeError: 'tuple' object has no attribute 'infer'
how do your test runs fair?
Originally reported by: Anonymous
The pylint exit status code still returns that an error message was issued (ret | 2)
even if I explicitly ignore the error with:
# pylint: disable=E0611
Is there any way I can change this behavior?
Originally reported by: BitBucket: horneds
Im the author of some code-quality libraries such as https://github.com/klen/pylama. I use that in my VIM plugin
https://github.com/klen/python-mode. Pylama is simular to flake8, but have some additional features and works also with pylint.
Today I would like to make code checking with pylama is more asynchronously. I haven't any problems with pyflake, pep8, pep257 and mccabe but cannot make pylint works. When I run pylint with a few threads I get errors like this: https://gist.github.com/klen/5721176. When one thread try to run pylint a more from one time I got this error.
I think the problem in ASTNG MANAGER and I try to clean that cache.
I tried to clear the cache in several ways https://gist.github.com/klen/5721225 but not have success.
Any ideas?
Originally reported by: Andrew Pennebaker (BitBucket: mcandre, GitHub: @mcandre?)
I would like to customize the indentation width, but I don't know which warning applies, in the output:
#!shell
W: 24,0: Bad indentation. Found 2 spaces, expected 4
W: 26,0: Bad indentation. Found 2 spaces, expected 4
W: 29,0: Bad indentation. Found 2 spaces, expected 4
W: 31,0: Bad indentation. Found 2 spaces, expected 4
And even this were made clear, I don't know how to customize the warning in a pylintrc file. I know how to use .jshintrc files to customize JSHint, but pylint offers little documentation by comparison.
Originally reported by: Anonymous
I just tried to upgrade pylint to 1.0.0 (via pip), and when I try to run it, I get a VersionConflict traceback for a version of logilab-common that hasn't been released yet.
$ pylint -h
Traceback (most recent call last):
File "/usr/local/bin/pylint", line 5, in
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2854, in
parse_requirements(requires), Environment()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 598, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (logilab-common 0.59.1 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('logilab-common>=0.60.0'))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.