[Python-modules-commits] [pylama] 06/09: Import pylama_7.3.1.orig.tar.gz
ChangZhuo Chen
czchen at moszumanska.debian.org
Thu Dec 15 00:54:20 UTC 2016
This is an automated email from the git hooks/post-receive script.
czchen pushed a commit to branch master
in repository pylama.
commit 3939aaee4eda32cd10e72f526ac47e35e0aa064e
Author: ChangZhuo Chen (陳昌倬) <czchen at debian.org>
Date: Wed Dec 14 09:10:00 2016 +0800
Import pylama_7.3.1.orig.tar.gz
---
Changelog | 5 ++++
PKG-INFO | 24 +++++++++--------
README.rst | 20 +++++++-------
pylama.egg-info/PKG-INFO | 24 +++++++++--------
pylama.egg-info/SOURCES.txt | 5 ++--
pylama.egg-info/requires.txt | 4 +--
pylama/__init__.py | 5 ++--
pylama/config.py | 14 +++++-----
pylama/core.py | 2 +-
pylama/errors.py | 11 +++++++-
pylama/hook.py | 13 +++++----
pylama/lint/extensions.py | 11 ++++++--
.../lint/{pylama_pep8.py => pylama_pycodestyle.py} | 18 ++++++-------
pylama/lint/pylama_pydocstyle.py | 12 ++++++---
pylama/lint/pylama_pyflakes.py | 11 ++++----
pylama/lint/pylama_radon.py | 31 ++++++++++++++++++++++
pylama/main.py | 2 +-
pylama/pytest.py | 2 +-
requirements.txt | 5 ++--
setup.py | 2 +-
20 files changed, 142 insertions(+), 79 deletions(-)
diff --git a/Changelog b/Changelog
index b06e0c8..8b8cb0f 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,8 @@
+2016-10-25 horneds
+
+ * Version 7.2.0
+ * Replace PEP8 with pycodestyle (c) Serg Baburin
+
2015-08-17 k.klenov
* --abspath
diff --git a/PKG-INFO b/PKG-INFO
index f741092..60dd522 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pylama
-Version: 7.1.0
+Version: 7.3.1
Summary: pylama -- Code audit tool for python
Home-page: http://github.com/klen/pylama
@@ -14,11 +14,12 @@ Description: |logo| Pylama
Code audit tool for Python and JavaScript. Pylama wraps these tools:
- * PEP8_ © 2012-2013, Florent Xicluna;
+ * pycodestyle_ (formerly pep8) © 2012-2013, Florent Xicluna;
* pydocstyle_ (formerly pep257 by Vladimir Keleshev) © 2014, Amir Rachum;
* PyFlakes_ © 2005-2013, Kevin Watters;
* Mccabe_ © Ned Batchelder;
* Pylint_ © 2013, Logilab (should be installed 'pylama_pylint' module);
+ * Radon_ © Michele Lacchia
* gjslint_ © The Closure Linter Authors (should be installed 'pylama_gjslint' module);
.. _badges:
@@ -76,7 +77,7 @@ Description: |logo| Pylama
==========
**Pylama** is easy to use and really fun for checking code quality.
- Just run `pylama` and get common output from all pylama plugins (PEP8_, PyFlakes_ and etc)
+ Just run `pylama` and get common output from all pylama plugins (pycodestyle_, PyFlakes_ and etc)
Recursive check the current directory. ::
@@ -94,7 +95,7 @@ Description: |logo| Pylama
Choose code checkers ::
- $ pylama -l "pep8,mccabe"
+ $ pylama -l "pycodestyle,mccabe"
Choose code checkers for JavaScript::
@@ -112,7 +113,7 @@ Description: |logo| Pylama
$ pylama --help
- usage: pylama [-h] [--verbose] [--version] [--format {pep8,pylint}]
+ usage: pylama [-h] [--verbose] [--version] [--format {pycodestyle,pylint}]
[--select SELECT] [--sort SORT] [--linters LINTERS]
[--ignore IGNORE] [--skip SKIP] [--report REPORT] [--hook]
[--async] [--options OPTIONS] [--force] [--abspath]
@@ -127,14 +128,14 @@ Description: |logo| Pylama
-h, --help show this help message and exit
--verbose, -v Verbose mode.
--version show program's version number and exit
- --format {pep8,pylint}, -f {pep8,pylint}
- Choose errors format (pep8, pylint).
+ --format {pycodestyle,pylint}, -f {pycodestyle,pylint}
+ Choose errors format (pycodestyle, pylint).
--select SELECT, -s SELECT
Select errors and warnings. (comma-separated list)
--sort SORT Sort result by error types. Ex. E,W,D
--linters LINTERS, -l LINTERS
Select linters. (comma-separated). Choices are
- mccabe,pep8,pyflakes,pydocstyle.
+ mccabe,pycodestyle,pyflakes,pydocstyle.
--ignore IGNORE, -i IGNORE
Ignore errors and warnings. (comma-separated)
--skip SKIP Skip files by masks (comma-separated, Ex.
@@ -230,7 +231,7 @@ Description: |logo| Pylama
[pylama:pyflakes]
builtins = _
- [pylama:pep8]
+ [pylama:pycodestyle]
max_line_length = 100
[pylama:pylint]
@@ -383,16 +384,17 @@ Description: |logo| Pylama
.. _BSD license: http://www.linfo.org/bsdlicense.html
.. _Mccabe: http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
.. _pydocstyle: https://github.com/PyCQA/pydocstyle/
- .. _PEP8: https://github.com/jcrocholl/pep8
+ .. _pycodestyle: https://github.com/PyCQA/pycodestyle
.. _PyFlakes: https://github.com/pyflakes/pyflakes
.. _Pylint: http://pylint.org
.. _Pytest: http://pytest.org
.. _gjslint: https://developers.google.com/closure/utilities
.. _klen: http://klen.github.io/
+ .. _Radon: https://github.com/rubik/radon
.. |logo| image:: https://raw.github.com/klen/pylama/develop/docs/_static/logo.png
:width: 100
-Keywords: pylint,pep8,pyflakes,mccabe,linter,qa,pep257,pydocstyle
+Keywords: pylint,pep8,pycodestyle,pyflakes,mccabe,linter,qa,pep257,pydocstyle
Platform: Any
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
diff --git a/README.rst b/README.rst
index 8e2ffae..15de719 100644
--- a/README.rst
+++ b/README.rst
@@ -5,11 +5,12 @@
Code audit tool for Python and JavaScript. Pylama wraps these tools:
-* PEP8_ © 2012-2013, Florent Xicluna;
+* pycodestyle_ (formerly pep8) © 2012-2013, Florent Xicluna;
* pydocstyle_ (formerly pep257 by Vladimir Keleshev) © 2014, Amir Rachum;
* PyFlakes_ © 2005-2013, Kevin Watters;
* Mccabe_ © Ned Batchelder;
* Pylint_ © 2013, Logilab (should be installed 'pylama_pylint' module);
+* Radon_ © Michele Lacchia
* gjslint_ © The Closure Linter Authors (should be installed 'pylama_gjslint' module);
.. _badges:
@@ -67,7 +68,7 @@ Quickstart
==========
**Pylama** is easy to use and really fun for checking code quality.
-Just run `pylama` and get common output from all pylama plugins (PEP8_, PyFlakes_ and etc)
+Just run `pylama` and get common output from all pylama plugins (pycodestyle_, PyFlakes_ and etc)
Recursive check the current directory. ::
@@ -85,7 +86,7 @@ Ignore errors ::
Choose code checkers ::
- $ pylama -l "pep8,mccabe"
+ $ pylama -l "pycodestyle,mccabe"
Choose code checkers for JavaScript::
@@ -103,7 +104,7 @@ Command line options
$ pylama --help
- usage: pylama [-h] [--verbose] [--version] [--format {pep8,pylint}]
+ usage: pylama [-h] [--verbose] [--version] [--format {pycodestyle,pylint}]
[--select SELECT] [--sort SORT] [--linters LINTERS]
[--ignore IGNORE] [--skip SKIP] [--report REPORT] [--hook]
[--async] [--options OPTIONS] [--force] [--abspath]
@@ -118,14 +119,14 @@ Command line options
-h, --help show this help message and exit
--verbose, -v Verbose mode.
--version show program's version number and exit
- --format {pep8,pylint}, -f {pep8,pylint}
- Choose errors format (pep8, pylint).
+ --format {pycodestyle,pylint}, -f {pycodestyle,pylint}
+ Choose errors format (pycodestyle, pylint).
--select SELECT, -s SELECT
Select errors and warnings. (comma-separated list)
--sort SORT Sort result by error types. Ex. E,W,D
--linters LINTERS, -l LINTERS
Select linters. (comma-separated). Choices are
- mccabe,pep8,pyflakes,pydocstyle.
+ mccabe,pycodestyle,pyflakes,pydocstyle.
--ignore IGNORE, -i IGNORE
Ignore errors and warnings. (comma-separated)
--skip SKIP Skip files by masks (comma-separated, Ex.
@@ -221,7 +222,7 @@ You could set options for special code checker with pylama configurations.
[pylama:pyflakes]
builtins = _
- [pylama:pep8]
+ [pylama:pycodestyle]
max_line_length = 100
[pylama:pylint]
@@ -374,11 +375,12 @@ Licensed under a `BSD license`_.
.. _BSD license: http://www.linfo.org/bsdlicense.html
.. _Mccabe: http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
.. _pydocstyle: https://github.com/PyCQA/pydocstyle/
-.. _PEP8: https://github.com/jcrocholl/pep8
+.. _pycodestyle: https://github.com/PyCQA/pycodestyle
.. _PyFlakes: https://github.com/pyflakes/pyflakes
.. _Pylint: http://pylint.org
.. _Pytest: http://pytest.org
.. _gjslint: https://developers.google.com/closure/utilities
.. _klen: http://klen.github.io/
+.. _Radon: https://github.com/rubik/radon
.. |logo| image:: https://raw.github.com/klen/pylama/develop/docs/_static/logo.png
:width: 100
diff --git a/pylama.egg-info/PKG-INFO b/pylama.egg-info/PKG-INFO
index f741092..60dd522 100644
--- a/pylama.egg-info/PKG-INFO
+++ b/pylama.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pylama
-Version: 7.1.0
+Version: 7.3.1
Summary: pylama -- Code audit tool for python
Home-page: http://github.com/klen/pylama
@@ -14,11 +14,12 @@ Description: |logo| Pylama
Code audit tool for Python and JavaScript. Pylama wraps these tools:
- * PEP8_ © 2012-2013, Florent Xicluna;
+ * pycodestyle_ (formerly pep8) © 2012-2013, Florent Xicluna;
* pydocstyle_ (formerly pep257 by Vladimir Keleshev) © 2014, Amir Rachum;
* PyFlakes_ © 2005-2013, Kevin Watters;
* Mccabe_ © Ned Batchelder;
* Pylint_ © 2013, Logilab (should be installed 'pylama_pylint' module);
+ * Radon_ © Michele Lacchia
* gjslint_ © The Closure Linter Authors (should be installed 'pylama_gjslint' module);
.. _badges:
@@ -76,7 +77,7 @@ Description: |logo| Pylama
==========
**Pylama** is easy to use and really fun for checking code quality.
- Just run `pylama` and get common output from all pylama plugins (PEP8_, PyFlakes_ and etc)
+ Just run `pylama` and get common output from all pylama plugins (pycodestyle_, PyFlakes_ and etc)
Recursive check the current directory. ::
@@ -94,7 +95,7 @@ Description: |logo| Pylama
Choose code checkers ::
- $ pylama -l "pep8,mccabe"
+ $ pylama -l "pycodestyle,mccabe"
Choose code checkers for JavaScript::
@@ -112,7 +113,7 @@ Description: |logo| Pylama
$ pylama --help
- usage: pylama [-h] [--verbose] [--version] [--format {pep8,pylint}]
+ usage: pylama [-h] [--verbose] [--version] [--format {pycodestyle,pylint}]
[--select SELECT] [--sort SORT] [--linters LINTERS]
[--ignore IGNORE] [--skip SKIP] [--report REPORT] [--hook]
[--async] [--options OPTIONS] [--force] [--abspath]
@@ -127,14 +128,14 @@ Description: |logo| Pylama
-h, --help show this help message and exit
--verbose, -v Verbose mode.
--version show program's version number and exit
- --format {pep8,pylint}, -f {pep8,pylint}
- Choose errors format (pep8, pylint).
+ --format {pycodestyle,pylint}, -f {pycodestyle,pylint}
+ Choose errors format (pycodestyle, pylint).
--select SELECT, -s SELECT
Select errors and warnings. (comma-separated list)
--sort SORT Sort result by error types. Ex. E,W,D
--linters LINTERS, -l LINTERS
Select linters. (comma-separated). Choices are
- mccabe,pep8,pyflakes,pydocstyle.
+ mccabe,pycodestyle,pyflakes,pydocstyle.
--ignore IGNORE, -i IGNORE
Ignore errors and warnings. (comma-separated)
--skip SKIP Skip files by masks (comma-separated, Ex.
@@ -230,7 +231,7 @@ Description: |logo| Pylama
[pylama:pyflakes]
builtins = _
- [pylama:pep8]
+ [pylama:pycodestyle]
max_line_length = 100
[pylama:pylint]
@@ -383,16 +384,17 @@ Description: |logo| Pylama
.. _BSD license: http://www.linfo.org/bsdlicense.html
.. _Mccabe: http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
.. _pydocstyle: https://github.com/PyCQA/pydocstyle/
- .. _PEP8: https://github.com/jcrocholl/pep8
+ .. _pycodestyle: https://github.com/PyCQA/pycodestyle
.. _PyFlakes: https://github.com/pyflakes/pyflakes
.. _Pylint: http://pylint.org
.. _Pytest: http://pytest.org
.. _gjslint: https://developers.google.com/closure/utilities
.. _klen: http://klen.github.io/
+ .. _Radon: https://github.com/rubik/radon
.. |logo| image:: https://raw.github.com/klen/pylama/develop/docs/_static/logo.png
:width: 100
-Keywords: pylint,pep8,pyflakes,mccabe,linter,qa,pep257,pydocstyle
+Keywords: pylint,pep8,pycodestyle,pyflakes,mccabe,linter,qa,pep257,pydocstyle
Platform: Any
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
diff --git a/pylama.egg-info/SOURCES.txt b/pylama.egg-info/SOURCES.txt
index b8b1351..30bdba5 100644
--- a/pylama.egg-info/SOURCES.txt
+++ b/pylama.egg-info/SOURCES.txt
@@ -28,6 +28,7 @@ pylama/libs/inirama.py
pylama/lint/__init__.py
pylama/lint/extensions.py
pylama/lint/pylama_mccabe.py
-pylama/lint/pylama_pep8.py
+pylama/lint/pylama_pycodestyle.py
pylama/lint/pylama_pydocstyle.py
-pylama/lint/pylama_pyflakes.py
\ No newline at end of file
+pylama/lint/pylama_pyflakes.py
+pylama/lint/pylama_radon.py
\ No newline at end of file
diff --git a/pylama.egg-info/requires.txt b/pylama.egg-info/requires.txt
index d1662e6..bfc8f4d 100644
--- a/pylama.egg-info/requires.txt
+++ b/pylama.egg-info/requires.txt
@@ -1,4 +1,4 @@
mccabe >= 0.5.2
-pydocstyle >= 1.0.0
-pep8 >= 1.7.0
+pycodestyle >= 2.0.0
+pydocstyle >= 1.1.1
pyflakes >= 1.3.0
diff --git a/pylama/__init__.py b/pylama/__init__.py
index c1e6c34..40c6e1f 100644
--- a/pylama/__init__.py
+++ b/pylama/__init__.py
@@ -1,11 +1,10 @@
-"""
-Code audit tool for python.
+"""Code audit tool for python.
:copyright: 2013 by Kirill Klenov.
:license: BSD, see LICENSE for more details.
"""
-__version__ = "7.1.0"
+__version__ = "7.3.1"
__project__ = "pylama"
__author__ = "Kirill Klenov <horneds at gmail.com>"
__license__ = "GNU LGPL"
diff --git a/pylama/config.py b/pylama/config.py
index 46da225..937f117 100644
--- a/pylama/config.py
+++ b/pylama/config.py
@@ -12,7 +12,7 @@ from .libs.inirama import Namespace
from .lint.extensions import LINTERS
#: A default checkers
-DEFAULT_LINTERS = 'pep8', 'pyflakes', 'mccabe'
+DEFAULT_LINTERS = 'pycodestyle', 'pyflakes', 'mccabe'
CURDIR = os.getcwd()
CONFIG_FILES = 'pylama.ini', 'setup.cfg', 'tox.ini', 'pytest.ini'
@@ -49,8 +49,8 @@ def split_csp_str(s):
"""
seen = set()
- l = s if isinstance(s, (list, tuple)) else s.strip().split(',')
- return [x for x in l if x and not (x in seen or seen.add(x))]
+ values = s if isinstance(s, (list, tuple)) else s.strip().split(',')
+ return [x for x in values if x and not (x in seen or seen.add(x))]
def parse_linters(linters):
@@ -81,9 +81,9 @@ PARSER.add_argument('--version', action='version',
version='%(prog)s ' + __version__)
PARSER.add_argument(
- "--format", "-f", default=_Default('pep8'),
- choices=['pep8', 'pylint', 'parsable'],
- help="Choose errors format (pep8, pylint, parsable).")
+ "--format", "-f", default=_Default('pycodestyle'),
+ choices=['pep8', 'pycodestyle', 'pylint', 'parsable'],
+ help="Choose errors format (pycodestyle, pylint, parsable).")
PARSER.add_argument(
"--select", "-s", default=_Default(''), type=split_csp_str,
@@ -152,7 +152,7 @@ def parse_options(args=None, config=True, rootdir=CURDIR, **overrides): # noqa
for k, v in overrides.items():
passed_value = getattr(options, k, _Default())
if isinstance(passed_value, _Default):
- setattr(options, k, _Default(v))
+ setattr(options, k, process_value(k, v))
# Compile options from ini
if config:
diff --git a/pylama/core.py b/pylama/core.py
index d68f6a9..cb5a1f2 100644
--- a/pylama/core.py
+++ b/pylama/core.py
@@ -81,7 +81,7 @@ def run(path='', code=None, rootdir=CURDIR, options=None):
import traceback
LOGGER.info(traceback.format_exc())
- errors = filter_errors(errors, **params)
+ errors = filter_errors(errors, **params) # noqa
errors = list(remove_duplicates(errors))
diff --git a/pylama/errors.py b/pylama/errors.py
index 71d13e9..785454a 100644
--- a/pylama/errors.py
+++ b/pylama/errors.py
@@ -9,6 +9,7 @@ PATTERN_NUMBER = re.compile(r'^[A-Z]\d+$')
DUPLICATES = (
# multiple statements on one line
+ [('pycodestyle', 'E701'), ('pylint', 'C0321')],
[('pep8', 'E701'), ('pylint', 'C0321')],
# unused variable
@@ -21,30 +22,38 @@ DUPLICATES = (
[('pylint', 'W0611'), ('pyflakes', 'W0611')],
# whitespace before ')'
+ [('pylint', 'C0326'), ('pycodestyle', 'E202')],
[('pylint', 'C0326'), ('pep8', 'E202')],
# whitespace before '('
+ [('pylint', 'C0326'), ('pycodestyle', 'E211')],
[('pylint', 'C0326'), ('pep8', 'E211')],
# multiple spaces after operator
+ [('pylint', 'C0326'), ('pycodestyle', 'E222')],
[('pylint', 'C0326'), ('pep8', 'E222')],
# missing whitespace around operator
+ [('pylint', 'C0326'), ('pycodestyle', 'E225')],
[('pylint', 'C0326'), ('pep8', 'E225')],
# unexpected spaces
+ [('pylint', 'C0326'), ('pycodestyle', 'E251')],
[('pylint', 'C0326'), ('pep8', 'E251')],
# long lines
+ [('pylint', 'C0301'), ('pycodestyle', 'E501')],
[('pylint', 'C0301'), ('pep8', 'E501')],
# statement ends with a semicolon
+ [('pylint', 'W0301'), ('pycodestyle', 'E703')],
[('pylint', 'W0301'), ('pep8', 'E703')],
# multiple statements on one line
- [('pylint', 'C0321'), ('pep8', 'E702')],
+ [('pylint', 'C0321'), ('pycodestyle', 'E702')],
# bad indentation
+ [('pylint', 'W0311'), ('pycodestyle', 'E111')],
[('pylint', 'W0311'), ('pep8', 'E111')],
# wildcart import
diff --git a/pylama/hook.py b/pylama/hook.py
index a48d596..04f40ca 100644
--- a/pylama/hook.py
+++ b/pylama/hook.py
@@ -1,4 +1,4 @@
-""" SCM hooks. Integration with git and mercurial. """
+"""SCM hooks. Integration with git and mercurial."""
from __future__ import absolute_import
@@ -20,7 +20,6 @@ def run(command):
"""Run a shell command.
:return str: Stdout
-
"""
p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
(stdout, stderr) = p.communicate()
@@ -28,19 +27,19 @@ def run(command):
[line.strip() for line in stderr.splitlines()])
-def git_hook():
- """Run pylama after git commit. """
+def git_hook(error=True):
+ """Run pylama after git commit."""
_, files_modified, _ = run("git diff-index --cached --name-only HEAD")
options = parse_options()
setup_logger(options)
candidates = list(map(str, files_modified))
if candidates:
- process_paths(options, candidates=candidates)
+ process_paths(options, candidates=candidates, error=error)
def hg_hook(ui, repo, node=None, **kwargs):
- """ Run pylama after mercurial commit. """
+ """Run pylama after mercurial commit."""
seen = set()
paths = []
if len(repo):
@@ -59,7 +58,7 @@ def hg_hook(ui, repo, node=None, **kwargs):
def install_git(path):
- """ Install hook in Git repository. """
+ """Install hook in Git repository."""
hook = op.join(path, 'pre-commit')
with open(hook, 'w') as fd:
fd.write("""#!/usr/bin/env python
diff --git a/pylama/lint/extensions.py b/pylama/lint/extensions.py
index 662d6ee..9a2ab4c 100644
--- a/pylama/lint/extensions.py
+++ b/pylama/lint/extensions.py
@@ -16,8 +16,9 @@ except ImportError:
pass
try:
- from pylama.lint.pylama_pep8 import Linter
- LINTERS['pep8'] = Linter()
+ from pylama.lint.pylama_pycodestyle import Linter
+ LINTERS['pep8'] = Linter() # for compability
+ LINTERS['pycodestyle'] = Linter()
except ImportError:
pass
@@ -27,6 +28,12 @@ try:
except ImportError:
pass
+try:
+ from pylama.lint.pylama_radon import Linter
+ LINTERS['radon'] = Linter()
+except ImportError:
+ pass
+
from pkg_resources import iter_entry_points
diff --git a/pylama/lint/pylama_pep8.py b/pylama/lint/pylama_pycodestyle.py
similarity index 76%
rename from pylama/lint/pylama_pep8.py
rename to pylama/lint/pylama_pycodestyle.py
index 30329d8..cf9e245 100644
--- a/pylama/lint/pylama_pep8.py
+++ b/pylama/lint/pylama_pycodestyle.py
@@ -1,5 +1,5 @@
-"""PEP8 support."""
-from pep8 import BaseReport, StyleGuide, get_parser
+"""pycodestyle support."""
+from pycodestyle import BaseReport, StyleGuide, get_parser
from pylama.lint import Linter as Abstract
@@ -12,11 +12,11 @@ except ImportError:
class Linter(Abstract):
- """PEP8 runner."""
+ """pycodestyle runner."""
@staticmethod
def run(path, code=None, params=None, **meta):
- """Check code with PEP8.
+ """Check code with pycodestyle.
:return list: List of errors.
"""
@@ -27,26 +27,26 @@ class Linter(Abstract):
if not isinstance(value, str):
continue
params[option.dest] = option.convert_value(option, params[option.dest])
- P8Style = StyleGuide(reporter=_PEP8Report, **params)
+ P8Style = StyleGuide(reporter=_PycodestyleReport, **params)
buf = StringIO(code)
return P8Style.input_file(path, lines=buf.readlines())
-class _PEP8Report(BaseReport):
+class _PycodestyleReport(BaseReport):
def __init__(self, *args, **kwargs):
- super(_PEP8Report, self).__init__(*args, **kwargs)
+ super(_PycodestyleReport, self).__init__(*args, **kwargs)
self.errors = []
def init_file(self, filename, lines, expected, line_offset):
"""Prepare storage for errors."""
- super(_PEP8Report, self).init_file(
+ super(_PycodestyleReport, self).init_file(
filename, lines, expected, line_offset)
self.errors = []
def error(self, line_number, offset, text, check):
"""Save errors."""
- code = super(_PEP8Report, self).error(
+ code = super(_PycodestyleReport, self).error(
line_number, offset, text, check)
if code:
diff --git a/pylama/lint/pylama_pydocstyle.py b/pylama/lint/pylama_pydocstyle.py
index 33d94f7..9f6c1d4 100644
--- a/pylama/lint/pylama_pydocstyle.py
+++ b/pylama/lint/pylama_pydocstyle.py
@@ -15,7 +15,11 @@ class Linter(Abstract):
:return list: List of errors.
"""
- return [
- {'lnum': e.line, 'text': e.message, 'type': 'D', 'number': e.code}
- for e in PEP257Checker().check_source(code, path)
- ]
+ return [{
+ 'lnum': e.line,
+ # Remove colon after error code ("D403: ..." => "D403 ...").
+ 'text': (e.message[0:4] + e.message[5:]
+ if e.message[4] == ':' else e.message),
+ 'type': 'D',
+ 'number': e.code
+ } for e in PEP257Checker().check_source(code, path)]
diff --git a/pylama/lint/pylama_pyflakes.py b/pylama/lint/pylama_pyflakes.py
index 61d1e8b..9f44fe6 100644
--- a/pylama/lint/pylama_pyflakes.py
+++ b/pylama/lint/pylama_pyflakes.py
@@ -22,8 +22,8 @@ checker.messages.ReturnWithArgsInsideGenerator.message = "E0106 'return' with ar
checker.messages.ReturnOutsideFunction.message = "E0104 'return' outside function"
-class Linter(Abstract):
+class Linter(Abstract):
"""Pyflakes runner."""
@staticmethod
@@ -42,9 +42,10 @@ class Linter(Abstract):
tree = compile(code, path, "exec", _ast.PyCF_ONLY_AST)
w = checker.Checker(tree, path, builtins=builtins)
w.messages = sorted(w.messages, key=lambda m: m.lineno)
- return [
- {'lnum': m.lineno, 'text': m.message % m.message_args}
- for m in sorted(w.messages, key=lambda m: m.lineno)
- ]
+ return [{
+ 'lnum': m.lineno,
+ 'text': m.message % m.message_args,
+ 'type': m.message[0]
+ } for m in w.messages]
# pylama:ignore=E501,C0301
diff --git a/pylama/lint/pylama_radon.py b/pylama/lint/pylama_radon.py
new file mode 100644
index 0000000..2b1d98c
--- /dev/null
+++ b/pylama/lint/pylama_radon.py
@@ -0,0 +1,31 @@
+from radon.visitors import ComplexityVisitor
+from radon.complexity import add_inner_blocks
+
+from pylama.lint import Linter as Abstract
+
+
+class Linter(Abstract):
+
+ """Radon runner."""
+
+ @staticmethod
+ def run(path, code=None, params=None, ignore=None, select=None, **meta):
+ """Check code with Radon.
+
+ :return list: List of errors.
+ """
+ complexity = params.get('complexity', 10)
+ no_assert = params.get('no_assert', False)
+ show_closures = params.get('show_closures', False)
+
+ visitor = ComplexityVisitor.from_code(code, no_assert=no_assert)
+ blocks = visitor.blocks
+ if show_closures:
+ blocks = add_inner_blocks(blocks)
+
+ return [
+ {'lnum': block.lineno, 'col': block.col_offset, 'type': 'R', 'number': 'R709',
+ 'text': 'R701: %s is too complex %d' % (block.name, block.complexity)}
+ for block in visitor.blocks if block.complexity > complexity
+ ]
+
diff --git a/pylama/main.py b/pylama/main.py
index b343e1e..cfcf01c 100644
--- a/pylama/main.py
+++ b/pylama/main.py
@@ -81,7 +81,7 @@ def process_paths(options, candidates=None, error=True):
"""Process files and log errors."""
errors = check_path(options, rootdir=CURDIR, candidates=candidates)
- if options.format == 'pep8':
+ if options.format in ['pycodestyle', 'pep8']:
pattern = "%(filename)s:%(lnum)s:%(col)s: %(text)s"
elif options.format == 'pylint':
pattern = "%(filename)s:%(lnum)s: [%(type)s] %(text)s"
diff --git a/pylama/pytest.py b/pylama/pytest.py
index eeaa58c..d982abf 100644
--- a/pylama/pytest.py
+++ b/pylama/pytest.py
@@ -43,7 +43,7 @@ class PylamaItem(pytest.Item, pytest.File):
def __init__(self, path, parent):
super(PylamaItem, self).__init__(path, parent)
- self.add_marker("pep8")
+ self.add_marker("pycodestyle")
self.cache = None
self._pylamamtimes = None
diff --git a/requirements.txt b/requirements.txt
index daca762..c7c6c83 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,7 @@
# Test requirements
mccabe >= 0.5.2
-pydocstyle >= 1.0.0
-pep8 >= 1.7.0
+pycodestyle >= 2.0.0
+pydocstyle >= 1.1.1
pyflakes >= 1.3.0
+# radon >= 1.4.2
diff --git a/setup.py b/setup.py
index 60273fd..c80532e 100644
--- a/setup.py
+++ b/setup.py
@@ -32,7 +32,7 @@ meta = dict(
long_description=_read('README.rst'),
platforms=('Any'),
zip_safe=False,
- keywords='pylint pep8 pyflakes mccabe linter qa pep257 pydocstyle'.split(),
+ keywords='pylint pep8 pycodestyle pyflakes mccabe linter qa pep257 pydocstyle'.split(),
author='Kirill Klenov',
author_email='horneds at gmail.com',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pylama.git
More information about the Python-modules-commits
mailing list