8000 Update pylama · python-mode/python-mode@c65773c · GitHub
[go: up one dir, main page]

Skip to content

Commit c65773c

Browse files
committed
Update pylama
1 parent 3e7aec0 commit c65773c

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

pymode/libs/pylama/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def run(path, code=None, options=None):
5353
item = (item, LINTERS.get(item))
5454

5555
name, linter = item
56+
LOGGER.debug("Run %s", name)
5657

5758
if not linter or not linter.allow(path):
5859
continue
@@ -70,16 +71,19 @@ def run(path, code=None, options=None):
7071
errors.append(e)
7172

7273
except IOError as e:
74+
LOGGER.debug("IOError %s", e)
7375
errors.append(dict(
7476
lnum=0, type='E', col=0, text=str(e), filename=path or ''))
7577

7678
except SyntaxError as e:
79+
LOGGER.debug("SyntaxError %s", e)
7780
errors.append(dict(
7881
lnum=e.lineno or 0, type='E', col=e.offset or 0,
7982
text=e.args[0] + ' [%s]' % name, filename=path or ''
8083
))
8184

82-
except Exception:
85+
except Exception as e:
86+
LOGGER.debug("Unknown exception %s", e)
8387
import traceback
8488
logging.debug(traceback.format_exc())
8589

pymode/libs/pylama/lint/extensions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
for p in listdir(CURDIR):
1616
if p.startswith(PREFIX) and op.isdir(op.join(CURDIR, p)):
1717
name = p[len(PREFIX):]
18-
module = import_module('.lint.%s%s' % (PREFIX, name), 'pylama')
19-
LINTERS[name] = getattr(module, 'Linter')()
18+
try:
19+
module = import_module('.lint.%s%s' % (PREFIX, name), 'pylama')
20+
LINTERS[name] = getattr(module, 'Linter')()
21+
except ImportError:
22+
continue
2023

2124
try:
2225
from pkg_resources import iter_entry_points

pymode/libs/pylama/lint/pylama_pyflakes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ class Linter(BaseLinter):
88
""" Pyflakes code check. """
99

1010
@staticmethod
11-
def run(path, code=None, builtins=None, **meta):
11+
def run(path, code=None, builtins="", **meta):
1212
""" Pyflake code checking.
1313
1414
:return list: List of errors.
1515
1616
"""
1717
import _ast
18-
from .pyflakes import checker
1918
import os
19+
from .pyflakes import checker
2020

2121
os.environ.setdefault('PYFLAKES_BUILTINS', builtins)
2222

pymode/libs/pylama/lint/pylama_pylint/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import os.path
1313
import sys
1414

15+
if sys.version_info >= (3, 0, 0):
16+
raise ImportError("pylama_pylint doesnt support python3")
17+
1518
CURDIR = os.path.abspath(os.path.dirname(__file__))
1619
sys.path.insert(0, CURDIR)
1720

1821
from .main import Linter
1922
assert Linter
20-

pymode/libs/pylama/lint/pylama_pylint/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,3 @@ def add_message(self, msg_id, location, msg):
5252
runner = Run(
5353
[path] + attrs, reporter=Reporter(), exit=False)
5454
return runner.linter.reporter.errors
55-

pymode/lint.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,34 @@ def code_check():
1313
1414
"""
1515

16-
from pylama.main import parse_options
17-
from pylama.tasks import check_path
16+
with silence_stderr():
1817

19-
if not env.curbuf.name:
20-
env.stop()
21-
return False
18+
from pylama.main import parse_options
19+
from pylama.tasks import check_path
2220

23-
options = parse_options(
24-
ignore=env.var('g:pymode_lint_ignore'),
25-
select=env.var('g:pymode_lint_select'),
26-
linters=env.var('g:pymode_lint_checkers'),
27-
)
21+
if not env.curbuf.name:
22+
return env.stop()
2823

29-
path = os.path.relpath(env.curbuf.name, env.curdir)
30-
env.debug("Start code check: ", path)
24+
options = parse_options(
25+
ignore=env.var('g:pymode_lint_ignore'),
26+
select=env.var('g:pymode_lint_select'),
27+
linters=env.var('g:pymode_lint_checkers'),
28+
)
3129

32-
if getattr(options, 'skip', None) and any(p.match(path) for p in options.skip): # noqa
33-
env.message('Skip code checking.')
34-
env.debug("Skipped")
35-
env.stop()
36-
return False
30+
path = os.path.relpath(env.curbuf.name, env.curdir)
31+
env.debug("Start code check: ", path)
3732

38-
if env.options.get('debug'):
39-
from pylama.core import LOGGER, logging
40-
LOGGER.setLevel(logging.DEBUG)
33+
if getattr(options, 'skip', None) and any(p.match(path) for p in options.skip): # noqa
34+
env.message('Skip code checking.')
35+
env.debug("Skipped")
36+
return env.stop()
4137

42-
with silence_stderr():
43-
errors = check_path(path, options=options,
44-
code='\n'.join(env.curbuf) + '\n')
38+
if env.options.get('debug'):
39+
from pylama.core import LOGGER, logging
40+
LOGGER.setLevel(logging.DEBUG)
41+
42+
errors = check_path(
43+
path, options=options, code='\n'.join(env.curbuf) + '\n')
4544

4645
env.debug("Find errors: ", len(errors))
4746
sort_rules = env.var('g:pymode_lint_sort')

0 commit comments

Comments
 (0)
0