Skip to content

Commit

Permalink
Merge branch 'release/5.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Jun 15, 2014
2 parents aa5948c + 867d87c commit 72fa42b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pylama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

__version__ = "5.0.3"
__version__ = "5.0.4"
__project__ = "pylama"
__author__ = "Kirill Klenov <horneds@gmail.com>"
__license__ = "GNU LGPL"
11 changes: 6 additions & 5 deletions pylama/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def run(path='', code=None, options=None):
with CodeContext(code, path) as ctx:
code = ctx.code
params = prepare_params(parse_modeline(code), fileconfig, options)
LOGGER.debug('Checking params: %s', params)

if params.get('skip'):
return errors
Expand All @@ -59,13 +60,13 @@ def run(path='', code=None, options=None):
if not linter:
continue

LOGGER.info("Run %s", lname)
lparams = linters_params.get(lname, dict())
errors += [
Error(filename=path, linter=lname, **e) for e in
linter.run(
LOGGER.info("Run %s %s", lname, lparams)

for er in linter.run(
path, code=code, ignore=params.get("ignore", set()),
select=params.get("select", set()), **lparams)]
select=params.get("select", set()), params=lparams):
errors.append(Error(filename=path, linter=lname, **er))

except IOError as e:
LOGGER.debug("IOError %s", e)
Expand Down
2 changes: 1 addition & 1 deletion pylama/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ def get(self, name, default=None):
def __repr__(self):
return "<Error: %s %s>" % (self.number, self.linter)

# pylama:ignore=W0622,D
# pylama:ignore=W0622,D,R0924
3 changes: 2 additions & 1 deletion pylama/lint/pylama_mccabe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ class Linter(BaseLinter):
""" Mccabe code complexity. """

@staticmethod
def run(path, code=None, complexity=10, **params):
def run(path, code=None, params=None, **meta):
""" MCCabe code checking.
:return list: List of errors.
"""
from .mccabe import get_code_complexity

complexity = params.get('complexity', 10)
return get_code_complexity(code, complexity, filename=path) or []
2 changes: 1 addition & 1 deletion pylama/lint/pylama_pep257/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Linter(BaseLinter):
""" Mccabe code complexity. """

@staticmethod
def run(path, code=None, **params):
def run(path, code=None, **meta):
""" PEP257 code checking.
:return list: List of errors.
Expand Down
2 changes: 1 addition & 1 deletion pylama/lint/pylama_pep8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Linter(BaseLinter):
""" PEP8 code check. """

@staticmethod
def run(path, code=None, ignore=None, select=None, **params):
def run(path, code=None, params=None, **meta):
""" PEP8 code checking.
:return list: List of errors.
Expand Down
4 changes: 3 additions & 1 deletion pylama/lint/pylama_pyflakes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ def __init__(self):
monkey_patch_messages(checker.messages)

@staticmethod
def run(path, code=None, builtins="", **params):
def run(path, code=None, params=None, **meta):
""" Pyflake code checking.
:return list: List of errors.
"""
import _ast

builtins = params.get("builtins", "")

if builtins:
builtins = builtins.split(",")

Expand Down
3 changes: 2 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_prepare_params():

def test_mccabe():
mccabe = LINTERS.get('mccabe')
errors = mccabe.run('dummy.py', '')
errors = mccabe.run('dummy.py', '', params={})
assert errors == []


Expand Down Expand Up @@ -96,6 +96,7 @@ def test_linters_params():
def test_ignore_select():
options = parse_options()
options.ignore = ['E301', 'D102']
options.linters = ['pep8', 'pep257', 'pyflakes', 'mccabe']
errors = run('dummy.py', options=options)
assert len(errors) == 17

Expand Down

0 comments on commit 72fa42b

Please sign in to comment.