klen / pylama Goto Github PK
View Code? Open in Web Editor NEWCode audit tool for python.
License: MIT License
Code audit tool for python.
License: MIT License
I would like to set my line length to 120 as opposed to 79.
It seems that pylama has no global option to specify line length config.
When running pep8 it is ignoring the global pep8 config file.
I have a project, where some python files/scripts do not end with '.py'.
Is it possible to include these files in my pytest.ini/pylama.ini
I tried pylama by explicitely selecting the file e.g. pylama path/to/file
, but pylama still ignores it.
When I rename the file to have a '.py' suffix pylama works.
Why are pylama collects all analysis results in memory? If run it on large project, OS will kill pylama due a memory leak.
Profiling result of pympler for little (requests-2.12.1, size: 2Mb, files:149) project:
from pylama.main import shell
from pympler.tracker import SummaryTracker
def pylama_start2():
errors2 = shell('-l pylint ../perf_test/requests-2.12.1/'.split(), error=False)
print(len(errors2))
tracker = SummaryTracker()
pylama_start2()
tracker.print_diff()
Messages count: 9638
types | # objects | total size
========================================== | =========== | ============
<class 'dict | 599403 | 179.31 MB
<class 'list | 503739 | 41.20 MB
<class 'str | 204213 | 15.59 MB
<class 'astroid.node_classes.Name | 138042 | 7.37 MB
<class 'int | 249007 | 6.65 MB
<class 'tuple | 82360 | 5.12 MB
<class 'set | 7235 | 3.71 MB
<class 'tokenize.TokenInfo | 42623 | 3.58 MB
<class 'astroid.node_classes.Const | 52532 | 2.81 MB
<class 'astroid.scoped_nodes.ClassDef | 47774 | 2.55 MB
<class 'astroid.node_classes.Arguments | 46631 | 2.49 MB
<class 'astroid.scoped_nodes.FunctionDef | 46535 | 2.49 MB
<class 'traceback | 36915 | 2.25 MB
<class 'astroid.node_classes.AssignName | 39898 | 2.13 MB
<class 'astroid.node_classes.Call | 31350 | 1.67 MB
Programs version.
$ python --version
Python 2.7.10
$ pip2 freeze | grep "pylama\|pylint"
pylama==7.0.6
pylama-gjslint==0.0.7
pylama-pylint==2.1.1
pylint==1.4.4
$ python3 --version
Python 3.4.3+
$ pip3 freeze | grep "pylama\|pylint"
pylama==7.0.6
pylama-gjslint==0.0.7
pylama-pylint==2.1.1
pylint==1.4.4
Error when using Pylint linter.
$ pylama -l pylint subdown.py
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pylint/lint.py", line 910, in get_ast
return MANAGER.ast_from_file(filepath, modname, source=True)
File "/usr/local/lib/python3.5/dist-packages/astroid/manager.py", line 112, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "/usr/local/lib/python3.5/dist-packages/astroid/builder.py", line 134, in file_build
module = self._data_build(data, modname, path)
File "/usr/local/lib/python3.5/dist-packages/astroid/builder.py", line 177, in _data_build
module = rebuilder.visit_module(node, modname, node_file, package)
File "/usr/local/lib/python3.5/dist-packages/astroid/rebuilder.py", line 148, in visit_module
newnode.body = [self.visit(child, newnode) for child in node.body]
File "/usr/local/lib/python3.5/dist-packages/astroid/rebuilder.py", line 148, in <listcomp>
newnode.body = [self.visit(child, newnode) for child in node.body]
File "/usr/local/lib/python3.5/dist-packages/astroid/rebuilder.py", line 161, in visit
return self._transform(visit_method(node, parent))
File "/usr/local/lib/python3.5/dist-packages/astroid/rebuilder.py", line 427, in visit_discard
newnode.value = self.visit(node.value, newnode)
File "/usr/local/lib/python3.5/dist-packages/astroid/rebuilder.py", line 161, in visit
return self._transform(visit_method(node, parent))
File "/usr/local/lib/python3.5/dist-packages/astroid/rebuilder.py", line 331, in visit_callfunc
if node.starargs is not None:
AttributeError: 'Call' object has no attribute 'starargs'
subdown.py:1:0: F0002 <class 'AttributeError'>: 'Call' object has no attribute 'starargs' [pylint]
I want to write additional comment text after # noqa:
skip_this_code() # noqa pylint:disable=...
But pylama ignores such comment and produces a warning. FYI flake8 accepts this comment and skips the line with such comment.
Should pylama_pylint
be in the requirements (preferably requirements-test.txt
)? I had to install it manually, in other case I got warnings WARNING:root:Linter
pylint not found
on every tests run.
If so, I can make a pull request adding this package to requirements.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/36983106-should-pylama_pylint-be-in-the-requirements?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).git_hook
and hg_hook
are filtering files with endswith('.py')
I guess that's a job for every Linter allow
method to avoid excluding other file types (like .js) from validation:
class Linter(lint.Linter):
""" Check code with gjlint """
def allow(self, path):
return path.endswith('.js')
I am not able to use pylint linter.
I made a virtualenv and run the tests
git clone https://github.com/klen/pylama.git
cd pylama
mkvirtualenv pylama
python setup.py develop
python setup.py test
There is this warning "WARNING:root:Linter pylint
not found." because pylama/lint/pylama_pylint
is missing.
There is also "dummy.py:15:80: E501 line too long (91 > 79 characters) [pep8]" which indicates, that tox.ini is either not read or the pep8 config max_line_length = 100
does not impact anything.
I have also problems to setup vim with python-mode, where you stated that one should create a pylama.ini
Feature Request:
Can you provide an option to output the absolute file path of the files?
Problem:
We use PyCharm for the python development. There you can run external tools like pylama. In the settings you can add a filter for the filepath, linenumber and column. This create clickable links to the files in the output of the external tools. Unfortunately this works only if the filepath is absolute.
Is it possible to add this option?
not sure if this was a mistake or not, but those files are nice to have when creating an rpm for a distribution
Currently I am working on creating Debian package for pylama (https://bugs.debian.org/779449). However, the content of pylama/__init__.py
is confused. The comment string says it is BSD license, but the LICENSE file is LGPL-3+.
"""
Code audit tool for python.
:copyright: 2013 by Kirill Klenov.
:license: BSD, see LICENSE for more details.
"""
__version__ = "7.0.9"
__project__ = "pylama"
__author__ = "Kirill Klenov <[email protected]>"
__license__ = "GNU LGPL"
Please help to clarify the actual license of this package by removing other license name/text in pylama so that we can work on Debian packaging, thanks.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/34617584-clarify-license-for-debian-packaging?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).I'm currently missing this from pylama: https://pypi.python.org/pypi/eradicate
Might be a nice addition. Would you suggest adding it in pylama or a separate linter?
This is somewhat hard to notice, since the directories libs
and lint
might be there from previous versions, but on a fresh install:
$ sudo pip install pylama
Downloading/unpacking pylama
Installing collected packages: pylama
Successfully installed pylama
Cleaning up...
$ pylama
Traceback (most recent call last):
File "/usr/bin/pylama", line 7, in <module>
from pylama.main import shell
File "/usr/lib/python2.7/site-packages/pylama/main.py", line 8, in <module>
from .config import parse_options, CURDIR, setup_logger
File "/usr/lib/python2.7/site-packages/pylama/config.py", line 11, in <module>
from .libs.inirama import Namespace
ImportError: No module named libs.inirama
(django_documentos)luzfcb@oficina:~/projetos/opensource/django_documentos$ pip install pylama
Collecting pylama
Downloading pylama-7.0.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): mccabe in /home/luzfcb/virtualenvs/django_documentos/lib/python2.7/site-packages (from pylama)
Requirement already satisfied (use --upgrade to upgrade): pep8 in /home/luzfcb/virtualenvs/django_documentos/lib/python2.7/site-packages (from pylama)
Requirement already satisfied (use --upgrade to upgrade): pyflakes in /home/luzfcb/virtualenvs/django_documentos/lib/python2.7/site-packages (from pylama)
Collecting pep257 (from pylama)
Downloading pep257-0.6.0.tar.gz
Building wheels for collected packages: pep257
Running setup.py bdist_wheel for pep257
Stored in directory: /home/luzfcb/.cache/pip/wheels/3b/cc/26/9dc89894b5852b3ee7335b2eb61e46cbeebac52504555ec4af
Successfully built pep257
Installing collected packages: pep257, pylama
Successfully installed pep257-0.6.0 pylama-7.0.0
(django_documentos)luzfcb@oficina:~/projetos/opensource/django_documentos$ pylama --version
Traceback (most recent call last):
File "/home/luzfcb/virtualenvs/django_documentos/bin/pylama", line 7, in <module>
from pylama.main import shell
File "/home/luzfcb/virtualenvs/django_documentos/local/lib/python2.7/site-packages/pylama/main.py", line 8, in <module>
from .config import parse_options, CURDIR, setup_logger
File "/home/luzfcb/virtualenvs/django_documentos/local/lib/python2.7/site-packages/pylama/config.py", line 12, in <module>
from .lint.extensions import LINTERS
File "/home/luzfcb/virtualenvs/django_documentos/local/lib/python2.7/site-packages/pylama/lint/extensions.py", line 24, in <module>
from pylama.lint.pylama_pyflakes import Linter
File "/home/luzfcb/virtualenvs/django_documentos/local/lib/python2.7/site-packages/pylama/lint/pylama_pyflakes.py", line 21, in <module>
checker.messages.ReturnOutsideFunction.message = "E0104 'return' outside function"
AttributeError: 'module' object has no attribute 'ReturnOutsideFunction'
(django_documentos)luzfcb@oficina:~/projetos/opensource/django_documentos$ pip install pylama -U
Requirement already up-to-date: pylama in /home/luzfcb/virtualenvs/django_documentos/lib/python2.7/site-packages
Requirement already up-to-date: mccabe in /home/luzfcb/virtualenvs/django_documentos/lib/python2.7/site-packages (from pylama)
Requirement already up-to-date: pep8 in /home/luzfcb/virtualenvs/django_documentos/lib/python2.7/site-packages (from pylama)
Collecting pyflakes (from pylama)
Downloading pyflakes-0.9.2-py2.py3-none-any.whl
Requirement already up-to-date: pep257 in /home/luzfcb/virtualenvs/django_documentos/lib/python2.7/site-packages (from pylama)
Installing collected packages: pyflakes
Found existing installation: pyflakes 0.8.1
Uninstalling pyflakes-0.8.1:
Successfully uninstalled pyflakes-0.8.1
Successfully installed pyflakes-0.9.2
(django_documentos)luzfcb@oficina:~/projetos/opensource/django_documentos$ pylama django_documentos tests
I have a mercurial installed globaly and pylama in a virtualenv.
When installing mercurial hooks they fail since mercurial can't import the hook and fails.
PyFlakes 1.1.0 is out and Pylama is throwing the following error:
Traceback (most recent call last):
File "/home/jsivak/projects/beat_matrix_checker_ve/bin/pylama", line 7, in <module>
from pylama.main import shell
File "/home/jsivak/projects/beat_matrix_checker_ve/lib/python2.7/site-packages/pylama/main.py", line 8, in <module>
from .config import parse_options, CURDIR, setup_logger
File "/home/jsivak/projects/beat_matrix_checker_ve/lib/python2.7/site-packages/pylama/config.py", line 12, in <module>
from .lint.extensions import LINTERS
File "/home/jsivak/projects/beat_matrix_checker_ve/lib/python2.7/site-packages/pylama/lint/extensions.py", line 35, in <module>
LINTERS[entry.name] = entry.load()()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2379, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2396, in require
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 833, in resolve
pkg_resources.ContextualVersionConflict: (pyflakes 1.1.0 (/home/jsivak/projects/beat_matrix_checker_ve/lib/python2.7/site-packages), Requirement.parse('pyflakes==1.0.0'), set(['pylama']))
Not sure if the requirements for Pylama just need to be updated or if there is some testing that Pylama needs to do to support Pyflakes 1.1.0.
When I manually update the METADATA file in my virtualenv's lib/python2.7/site-packages/pylama-7.0.7.dist-info directory:
from:
Requires-Dist: pyflakes (==1.0.0)
to:
Requires-Dist: pyflakes (>=1.0.0)
everything seems to work.
On python 2.7.3 / 3.2 / 3.3 pep257 seems to disable other linters: pep8, pyflakes, mccabe
On python 3.4 other linters seem to work.
pylama.ini:
[pylama]
linters = pep8,pyflakes,mccabe,pep257
I've got strange behavior with cache (pytest-cache integration fails i guess):
└─[1] <git:(master 3b9152f✱) > py.test pdt tests
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.4.0 -- py-1.4.26 -- pytest-2.7.0 -- /home/vagrant/workspace/pdt/.env/bin/python3
cachedir: /home/vagrant/workspace/pdt/.cache
rootdir: /home/vagrant/workspace/pdt, inifile: tox.ini
plugins: pep257, cache, pep8, django, pylama, cov
collected 27 items
pdt/__init__.py SKIPPED
pdt/settings.py SKIPPED
pdt/settings_build.py SKIPPED
pdt/settings_deployment.py SKIPPED
pdt/settings_local.py SKIPPED
pdt/settings_test.py SKIPPED
pdt/urls.py SKIPPED
pdt/wsgi.py SKIPPED
pdt/api/__init__.py SKIPPED
pdt/api/admin.py SKIPPED
pdt/api/models.py SKIPPED
pdt/api/urls.py SKIPPED
pdt/api/views.py SKIPPED
pdt/api/migrations/__init__.py SKIPPED
pdt/core/__init__.py SKIPPED
pdt/core/admin.py SKIPPED
pdt/core/models.py PASSED
pdt/core/views.py SKIPPED
pdt/core/migrations/0001_initial.py SKIPPED
pdt/core/migrations/__init__.py SKIPPED
tests/__init__.py SKIPPED
tests/conftest.py FAILED
tests/api/__init__.py SKIPPED
tests/api/test_api.py SKIPPED
tests/api/test_api.py::test_migration_filter_exclude_status PASSED
tests/api/test_api.py::test_migration_filter_status PASSED
tests/api/test_api.py::test_migration_filter_ci_project PASSED
==================================================================================================== FAILURES =====================================================================================================
________________________________________________________________________________________________________ _________________________________________________________________________________________________________
================================================================================= 1 failed, 4 passed, 22 skipped in 1.06 seconds ==================================================================================
and on next run:
└─[1] <git:(master 3b9152f✱) > py.test pdt tests
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.4.0 -- py-1.4.26 -- pytest-2.7.0 -- /home/vagrant/workspace/pdt/.env/bin/python3
cachedir: /home/vagrant/workspace/pdt/.cache
rootdir: /home/vagrant/workspace/pdt, inifile: tox.ini
plugins: pep257, cache, pep8, django, pylama, cov
collected 27 items
pdt/__init__.py SKIPPED
pdt/settings.py SKIPPED
pdt/settings_build.py SKIPPED
pdt/settings_deployment.py SKIPPED
pdt/settings_local.py SKIPPED
pdt/settings_test.py SKIPPED
pdt/urls.py SKIPPED
pdt/wsgi.py SKIPPED
pdt/api/__init__.py SKIPPED
pdt/api/admin.py SKIPPED
pdt/api/models.py SKIPPED
pdt/api/urls.py SKIPPED
pdt/api/views.py SKIPPED
pdt/api/migrations/__init__.py SKIPPED
pdt/core/__init__.py SKIPPED
pdt/core/admin.py SKIPPED
pdt/core/models.py SKIPPED
pdt/core/views.py SKIPPED
pdt/core/migrations/0001_initial.py SKIPPED
pdt/core/migrations/__init__.py SKIPPED
tests/__init__.py SKIPPED
tests/conftest.py FAILED
tests/api/__init__.py SKIPPED
tests/api/test_api.py SKIPPED
tests/api/test_api.py::test_migration_filter_exclude_status PASSED
tests/api/test_api.py::test_migration_filter_status PASSED
tests/api/test_api.py::test_migration_filter_ci_project PASSED
==================================================================================================== FAILURES =====================================================================================================
________________________________________________________________________________________________________ _________________________________________________________________________________________________________
tests/conftest.py:19:1: D102: Missing docstring in public method [pep257]
tests/conftest.py:22:1: D102: Missing docstring in public method [pep257]
tests/conftest.py:25:1: D102: Missing docstring in public method [pep257]
================================================================================= 1 failed, 3 passed, 23 skipped in 1.01 seconds ==================================================================================
so MORE errors appear on second run...
I guess it's because of cache.
Never had this issue with pytest-pep8, so i guess pytest-cache integration has some issues in pylama
I just tried to ammend commit with some files being removed and got this error message both in pylama 1.5.x and pylama 2.0.2 from commit hook:
,,,
some_file.py:0:0: [Errno 2] No such file or directory: 'some_file.py'
,,,
Also, commiting as a new commit gave the same error.
What is the "pylint" format based on?
The old default for pylint itself was "pylint --msg-template='{msg_id}:{line:3d},{column}: {obj}: {msg}'" and now is "{C}:{line:3d},{column:2d}: {msg} ({symbol})" (https://docs.pylint.org/en/1.6.0/output.html).
I would like to use pylama's pylint format, but it is missing the column.
pattern = "%(filename)s:%(lnum)s:%(col)s: %(text)s"
if options.format == 'pylint':
pattern = "%(filename)s:%(lnum)s: [%(type)s] %(text)s"
What do you think about specifying --pattern
?
And what about a default format that includes all information? (with type and col) :)
When I run pylama with the latest version of pylint (1.5.4 but also tried 1.5.0), I get a VersionConflict
exception. It doesn't happen when pylint is on an older version, 1.4.4.
oamasood@Osmans-MacBook-Pro:~/src/my-project$ pylama my_app/
Traceback (most recent call last):
File "/Users/oamasood/.pyenv/versions/2.7.9/bin/pylama", line 7, in <module>
from pylama.main import shell
File "/Users/oamasood/.pyenv/versions/2.7.9/lib/python2.7/site-packages/pylama/main.py", line 8, in <module>
from .config import parse_options, CURDIR, setup_logger
File "/Users/oamasood/.pyenv/versions/2.7.9/lib/python2.7/site-packages/pylama/config.py", line 12, in <module>
from .lint.extensions import LINTERS
File "/Users/oamasood/.pyenv/versions/2.7.9/lib/python2.7/site-packages/pylama/lint/extensions.py", line 35, in <module>
LINTERS[entry.name] = entry.load()()
File "/Users/oamasood/.pyenv/versions/2.7.9/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2354, in load
self.require(*args, **kwargs)
File "/Users/oamasood/.pyenv/versions/2.7.9/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2371, in require
items = working_set.resolve(reqs, env, installer)
File "/Users/oamasood/.pyenv/versions/2.7.9/lib/python2.7/site-packages/pkg_resources/__init__.py", line 844, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pylint 1.5.4 (/Users/oamasood/.pyenv/versions/2.7.9/lib/python2.7/site-packages), Requirement.parse('pylint==1.4.4'))
Setting --verbose
doesn't give any additional input. Here's my tox.ini
config:
[pylama]
skip = */.tox/*,*/.env/*,dashboard/*
linters = pylint,pep8,mccabe
format = pylint
[pylama:pep8]
max_line_length = 119
[pylama:pylint]
max_line_length = 119
[pylama:mccabe]
max-complexity = 10
When the pylint version is 1.4.4, it still gives me some errors on output, but it works:
Try to read configuration from:
Namespace(abspath=False, async=False, file_params={}, force=False, format='pylint', hook=False, ignore=[], linters=[('pep8', <pylama.lint.pylama_pep8.Linter object at 0x107142d50>), ('pylint', <pylama_pylint.main.Linter object at 0x1074eef50>), ('mccabe', <pylama.lint.pylama_mccabe.Linter object at 0x106fa4390>)], linters_params={u'pep8': {u'max_line_length': 119}, u'pylint': {u'max_line_length': 119}, u'mccabe': {u'max-complexity': 10}}, options='', paths=['my_app'], report=None, select=[], skip=[<_sre.SRE_Pattern object at 0x1079ac618>, <_sre.SRE_Pattern object at 0x1079ac8a0>, <_sre.SRE_Pattern object at 0x1079aa8b8>], sort=[], verbose=True)
File is reading: my_app/__init__.py
Run pep8 {u'max_line_length': 119}
Run pylint {u'max_line_length': 119}
Problem importing module classes.py: cannot import name InferenceContext
Problem importing module classes.pyc: cannot import name InferenceContext
Run mccabe {u'max-complexity': 10}
Any help would be appreciated... Thanks!
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30444767-pylama-doesn-t-work-with-latest-version-of-pylint?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).When i enter
pylama myfile.py
It prompt
myfile.py:1:1: W0401 'from swampy.TurtleWorld import *' used; unable to detect undefined names [pyflakes]
swampy is installed through pip.
Hello!
I have Windows 8 x64. I installed Miniconda2 on drive C: (C:\Miniconda2). Then I installed pylama using pip (pip install pylama). After that I tried to check file on drive E:
pylama E:\test_file.py
I got error:
ValueError: File is on drive E: start on drive C:
If I cd to E drive and than run file check then works fine. But because of this pylama doesn't works correctly in pylama-linter plugin for atom.
How can I fix it?
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/32389415-pylama-failes-to-check-file-on-other-drive-on-windows?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).see also https://github.com/GreenSteam/pep257
pytest --fixtures-per-test --pylama
========================= test session starts ================================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
Django settings: xyx.settings.test (from command line option)
rootdir: /opt/xyz, inifile: pytest.ini
plugins: django-3.1.2, cov-2.4.0, catchlog-1.2.2, pylama-7.3.3
collected 231 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/_pytest/main.py", line 98, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/_pytest/python.py", line 1031, in _show_fixtures_per_test
INTERNALERROR> write_item(item)
INTERNALERROR> File "/usr/local/lib/python2.7/site-packages/_pytest/python.py", line 1012, in write_item
INTERNALERROR> name2fixturedefs = item._fixtureinfo.name2fixturedefs
INTERNALERROR> AttributeError: 'PylamaItem' object has no attribute '_fixtureinfo'
=========================1 tests deselected ===================================
==================== 1 deselected in 0.15 seconds =============================
$ pytest --version
This is pytest version 3.0.5, imported from /usr/local/lib/python2.7/site-packages/pytest.pyc
setuptools registered plugins:
pytest-django-3.1.2 at /usr/local/lib/python2.7/site-packages/pytest_django/plugin.py
pytest-cov-2.4.0 at /usr/local/lib/python2.7/site-packages/pytest_cov/plugin.py
pytest-catchlog-1.2.2 at /usr/local/lib/python2.7/site-packages/pytest_catchlog.py
pylama-7.3.3 at /usr/local/lib/python2.7/site-packages/pylama/pytest.py
Hi,
this is more like a wishlist item.
I would love to see a way to suppress warnings by specifying that in an
external file. There are often situation when I would like to suppress a
PyLint warning based on a filename and/or content pattern. Putting active
comments into the source is just not an option for me.
For example, I would like to suppress the "too many public methods"
recommendation for the "TestCase" content pattern or suppress more specific
warnings at particular locations after I already considered alternatives.
I just stumbled upon this and thought this would be a good place to post this
because you describe the suppression through comments in the README.
Python-mode really improved my workflow. Thanks, and keep up the good work.
So the LOGGER
is not configured to output info
messages during config parsing.
There could be a setup_early_logger
method additionally?!
What's the plan for proper and documented Python 3.4-3.6 support?
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/39174788-python-3-4-3-6-support?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).flake8 supports multiple folders as input. this is very useful if you have several directories on the root directory
root_directory:
pylama.ini
setup.cfg
setup.py
app1/
app2/
app3/
It would be nice if I could run:
pylama app1 app2 app3
instead of
pylama app1
pylama app2
pylama app3
pep257 now has error codes support since its pull request #53 has been merged.
It would be nice to expose the new pep257 --ignore
option into pylama to allow user to silent some pep257 errors, as it's currently done with lint_ignore
option.
I have the following lines in my pylama.ini file
[pylama:*/init.py]
ignore = W0611
[pylama:bla/init.py]
ignore = E402,W0611
On one machine this works as expected (W0611 is ignored for all init.py files, while bla/init.py also ignores E402). But when the same code is checked on a different machine, with the same pylama version, it causes E402 errors to be found for bla/init.py.
So the title says it all I guess. Have you guys thought about wrapping mypy as well? Can this be done?
Thanks!
Usually errors D203, D212, D213 and D404 are ignored in pydocstyle
(see http://www.pydocstyle.org/en/latest/error_codes.html#default-checks). However, pylama
seems to ignore this.
Using a MWE:
"""Doc."""
def func():
"""First line.
Extra line.
"""
I see
$ pylama -lpydocstyle test.py
test.py:3:1: D213 Multi-line docstring summary should start at the second line [pydocstyle]
$ pylama -lpydocstyle --ignore=D213 test.py
$
Testing with pydocstyle
directly gives
$ pydocstyle test.py
$
$ pydocstyle --select=D213 test.py
test.py:3 in public function `func`:
D213: Multi-line docstring summary should start at the second line
Is this intended behavior?
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/40151744-wrong-handling-of-ignored-pydocstyle-errors?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).Hi,
We're keeping .ini file within repository, and it would be great, if we could use this ini file with hook installed by pylama in git repository
If a linter is listed in the configuration (eg: isort) pylama should fail if the linter is not found instead of giving only a warning:
Line 68 in 4e1994a
This could be implemented as a setting to enforce or not enforce.
I have installed pylama_pylint
but it seems that when running pylama
it isn't run.
Do I need to do something to get it running?
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/36596728-pylint-how-use-it?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F394650&utm_medium=issues&utm_source=github).What about adding radon support for code metrics?
In previous versions we've got
Linter `notexisting` not found'
It is more verbose. Also it could exit with non-zero code.
I've tried to install hook from nevest pylama version (7.0.0) and it unfortunately failed with this error.
Traceback (most recent call last):
File "/home/fizyk/.virtualenvs/dvreports/bin/pylama", line 11, in <module>
sys.exit(shell())
File "/home/fizyk/.virtualenvs/dvreports/local/lib/python2.7/site-packages/pylama/main.py", line 74, in shell
return install_hook(options.path)
AttributeError: 'Namespace' object has no attribute 'path'
haven't had time to look at this yet though
We are currently (ab)using the path
configuration option to define the top-level directory of the source code that should be scanned (best reason is to be more robust in the context of a continuous integration tool). Since the change in commit 7390602 the value returned by ArgumentParser is probably a list, but ConfigParser will still return a single string.
What's the right solution? Should we go back to skip all possible directories by hand (which is actually the only documented method) or attempt to fix this issue (which is roughly checking if the configuration argument is a string and split
it)?
Hello, pylama is very useful!
However, I have noticed that if I use pylint with pyflakes and pep8, there are many duplicate messages. Both pylint and pyflakes produce errors like E0602, which uses the same error number but slightly different messages. On the other hand, both pylint and pep8 generate things like a "line too long" message, but use different error codes (C0301 for pylint and E501 for pep8).
It would be great if, when using more than one linter, duplicates like the above could be reduced to just a single warning. Perhaps even the order of the linters could dictate which linter "wins" if more than one report the same message?
The following section (e.g. in tox.ini
) should also apply to the pep8
linter in pylama
:
[pep8]
ignore = E501
But it seems that only [pylama]
sections are honored, at least with the pep8
linter.
Having to specify both a [pep8]
and [pylama]
section makes using pylama
locally more intrusive (since the project might not use it, and therefore does not care about the added section).
The same applies to flake8
btw: it also does not use the [pep8]
section, but requires you to add a [flake8]
one.
Therefore I can imagine that this in done on purpose, since it allows you to treat the meta linters different?!
Does pylama treat all linters this way, or does it depend on the linters interface (i.e. some linter reads its config always)?
What about enabling using the linters setting by default and having a setting for [pylama]
to disable this (changed) behavior?
I would say that a [pylama]
section would still overwrite settings from [pep8]
then.
I have noticed that the formatting for "--format pep8" is inconsistent, because
it will not have a type field (E) and number:
Given t.py
:
= meh
% pylama -l mccabe,pep8,pyflakes,pep257 --format=pep8 t.py
t.py:1:2: E111 indentation is not a multiple of four [pep8]
t.py:1:2: E113 unexpected indentation [pep8]
t.py:1:1: unexpected indent [pyflakes]
This makes it more difficult to parse (e.g. using Vim's errorformat).
With --format=pylint:
% pylama -l mccabe,pep8,pyflakes,pep257 --format=pylint t.py
t.py:1: [D] D100: Missing docstring in public module [pep257]
t.py:1: [E] Invalid syntax: = meh [mccabe]
t.py:1: [E] unexpected indent [pyflakes]
(The same file with the "pylint" format gets different errors, which appears to
be a separate issue?! pep257 and mccabe is used here, but pep8 is not.
That happens when using pyflakes, which throws a SyntaxError from
pylama/pylama/lint/pylama_pyflakes.py
Line 41 in e9e926f
Whenever I try to run pylama, I get this error
Traceback (most recent call last):
File "/home/fizyk/.virtualenvs/ab/bin/pylama", line 9, in <module>
load_entry_point('pylama==1.4.0', 'console_scripts', 'pylama')()
File "/home/fizyk/.virtualenvs/ab/local/lib/python2.7/site-packages/pylama/main.py", line 43, in shell
return check_files(paths, options, error=error)
File "/home/fizyk/.virtualenvs/ab/local/lib/python2.7/site-packages/pylama/main.py", line 69, in check_files
errors = async_check_files(work_paths, options, rootpath=rootpath)
File "/home/fizyk/.virtualenvs/ab/local/lib/python2.7/site-packages/pylama/tasks.py", line 56, in async_check_files
errors += check_path(path, options=options, rootpath=rootpath)
File "/home/fizyk/.virtualenvs/ab/local/lib/python2.7/site-packages/pylama/tasks.py", line 102, in check_path
config=config, **meta):
File "/home/fizyk/.virtualenvs/ab/local/lib/python2.7/site-packages/pylama/core.py", line 83, in run
errors = filter_skiplines(code, errors)
UnboundLocalError: local variable 'code' referenced before assignment
It's for pylama from version 1.4 onwards. 1.3.3 works perfectly
i have this in tox.ini
[pytest]
norecursedirs = build .* .env media static deployment
addopts = -vvl --pylama
DJANGO_SETTINGS_MODULE=pdt.settings_test
[pylama]
format = pep8
skip = */.tox/*,*/.env/*,pdt/core/migrations/*
linters = pylint,mccabe,pep8,pep257
ignore = F0401,C0111,E731,D100
[pylama:pep8]
max_line_length = 120
when i run tests:
─[0] <git:(master 3b9152f✱✈) > py.test tests
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.4.0 -- py-1.4.26 -- pytest-2.7.0 -- /home/vagrant/workspace/pdt/.env/bin/python3
cachedir: /home/vagrant/workspace/pdt/.cache
rootdir: /home/vagrant/workspace/pdt, inifile: tox.ini
plugins: pep257, cache, pep8, django, pylama, cov
collected 7 items
tests/__init__.py SKIPPED
tests/conftest.py SKIPPED
tests/api/__init__.py SKIPPED
tests/api/test_api.py SKIPPED
tests/api/test_api.py::test_migration_filter_exclude_status PASSED
tests/api/test_api.py::test_migration_filter_status PASSED
tests/api/test_api.py::test_migration_filter_ci_project PASSED
======================================================================================= 3 passed, 4 skipped in 0.85 seconds =======================================================================================
but when i run pylama separately:
└─[0] <git:(master 3b9152f✱) > pylama tests
tests/conftest.py:19:23: W0622 Redefining built-in 'type' [pylint]
tests/conftest.py:51:19: W0621 Redefining name 'ci_project_name' from outer scope (line 39) [pylint]
tests/conftest.py:51:36: W0621 Redefining name 'ci_project_description' from outer scope (line 45) [pylint]
tests/conftest.py:69:50: W0621 Redefining name 'ci_project' from outer scope (line 51) [pylint]
tests/conftest.py:69:13: W0621 Redefining name 'instance_name' from outer scope (line 57) [pylint]
tests/conftest.py:69:28: W0621 Redefining name 'instance_description' from outer scope (line 63) [pylint]
tests/conftest.py:71:0: C0301 Line too long (111/100) [pylint]
tests/conftest.py:87:12: W0621 Redefining name 'release_name' from outer scope (line 75) [pylint]
tests/conftest.py:87:26: W0621 Redefining name 'release_date' from outer scope (line 81) [pylint]
tests/conftest.py:111:9: W0621 Redefining name 'case_id' from outer scope (line 93) [pylint]
tests/conftest.py:111:48: W0621 Redefining name 'ci_project' from outer scope (line 51) [pylint]
tests/conftest.py:111:30: W0621 Redefining name 'case_description' from outer scope (line 105) [pylint]
tests/conftest.py:111:18: W0621 Redefining name 'case_title' from outer scope (line 99) [pylint]
tests/conftest.py:111:60: W0621 Redefining name 'release' from outer scope (line 87) [pylint]
tests/conftest.py:114:0: C0301 Line too long (107/100) [pylint]
tests/conftest.py:121:28: W0108 Lambda may not be necessary [pylint]
tests/conftest.py:144:27: W0108 Lambda may not be necessary [pylint]
tests/conftest.py:156:28: W0108 Lambda may not be necessary [pylint]
tests/conftest.py:166:28: W0108 Lambda may not be necessary [pylint]
tests/api/test_api.py:31:0: C0330 Wrong hanging indentation. 'id': mr2.id, ^ | [pylint]
tests/api/test_api.py:32:0: C0330 Wrong hanging indentation. 'ci_project': migration.case.ci_project.name, ^ | [pylint]
tests/api/test_api.py:33:0: C0330 Wrong hanging indentation. 'instance': mr2.instance.name, ^ | [pylint]
tests/api/test_api.py:34:0: C0330 Wrong hanging indentation. 'status': mr2.status, ^ | [pylint]
tests/api/test_api.py:35:0: C0330 Wrong hanging indentation. 'datetime': equals_any, ^ | [pylint]
tests/api/test_api.py:36:0: C0330 Wrong hanging indentation. 'log': mr2.log}, ^ | [pylint]
tests/api/test_api.py:37:0: C0330 Wrong continued indentation. ] ^ | [pylint]
Hey,
When I try to git commit --amend with a file being renamed in changeset, I get the following error:
Traceback (most recent call last):
File ".git/hooks/pre-commit", line 6, in <module>
sys.exit(git_hook())
File "/home/fizyk/.virtualenvs/kanary/local/lib/python2.7/site-packages/pylama/hook.py", line 40, in git_hook
[f for f in map(str, files_modified) if f.endswith('.py')], options
File "/home/fizyk/.virtualenvs/kanary/local/lib/python2.7/site-packages/pylama/main.py", line 70, in check_files
errors = async_check_files(work_paths, options, rootpath=rootpath)
File "/home/fizyk/.virtualenvs/kanary/local/lib/python2.7/site-packages/pylama/tasks.py", line 57, in async_check_files
errors += check_path(path, options=options, rootpath=rootpath)
File "/home/fizyk/.virtualenvs/kanary/local/lib/python2.7/site-packages/pylama/tasks.py", line 103, in check_path
config=config):
File "/home/fizyk/.virtualenvs/kanary/local/lib/python2.7/site-packages/pylama/core.py", line 91, in run
errors = [er for er in errors if filter_errors(er, **params)]
UnboundLocalError: local variable 'params' referenced before assignment
It would be nice if we could ignore warnings and errors on a per block or per line basis much like # noqa
at the end of a line for example.
Use case:
mccabe
to be "too complex" but you don't have the time to fix it right now.My environment:
* Python 3.5.1
* pylama 7.0.9
* pylama-pylint 2.2.1
* pylint 1.5.4
My Test:
from os import path
def main() :
"""Some docstring."""
if path.exists('/tmp'):
return True
if __name__ = '__main__':
main()
Executed command:
pylama -l mccabe,pyflakes,pylint,pep8,pep257 -F --sort E,W,D -f pep8 test.py
Expected result:
test.py:11:0: E0001 invalid syntax [pylint]
test.py:11:13: invalid syntax [pyflakes]
test.py:1:1: D100: Missing docstring in public module [pep257]
test.py:4:11: E203 whitespace before ':' [pep8]
test.py:11:1: E303 too many blank lines (3) [pep8]
Real result:
Set of entries from expected result. Very rarely I'm able to see all expected results. Problem disappears when pyflakes plugin is disabled.
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.