Skip to content

Commit 14be21f

Browse files
committed
Fix linters
1 parent f2f7c06 commit 14be21f

File tree

1 file changed

+20
-37
lines changed

1 file changed

+20
-37
lines changed

pylibs/pymode.py

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ def check_file():
1313
for c in checkers:
1414
checker = globals().get(c)
1515
if checker:
16-
errors += checker(filename)
16+
try:
17+
errors += checker(filename)
18+
except SyntaxError, e:
19+
errors.append(dict(
20+
lnum = e.lineno,
21+
col = e.offset,
22+
text = e.args[0]
23+
))
24+
break
1725

1826
for e in errors:
1927
e.update(
@@ -38,16 +46,7 @@ def ignore_error(e):
3846

3947
def mccabe(filename):
4048
import mccabe as mc
41-
try:
42-
return mc.get_module_complexity(filename)
43-
except SyntaxError, e:
44-
lnum, col, msg = e.lineno, e.offset, e.text
45-
return [dict(
46-
lnum = lnum,
47-
col = col,
48-
text = msg,
49-
type = 'E'
50-
)]
49+
return mc.get_module_complexity(filename)
5150

5251

5352
def pep8(filename):
@@ -77,32 +76,16 @@ def pyflakes(filename):
7776

7877
codeString = file(filename, 'U').read() + '\n'
7978
errors = []
80-
try:
81-
tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST)
82-
83-
except SyntaxError, value:
84-
msg = value.args[0]
85-
if codeString is None:
86-
vim.command('echoerr "%s: problem decoding source"' % filename)
87-
else:
88-
lnum, col, _ = value.lineno, value.offset, value.text
89-
errors.append(dict(
90-
lnum = lnum,
91-
col = col,
92-
text = msg,
93-
type = 'E'
94-
))
95-
96-
else:
97-
w = checker.Checker(tree, filename)
98-
w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
99-
for w in w.messages:
100-
errors.append(dict(
101-
lnum = w.lineno,
102-
col = w.col,
103-
text = w.message % w.message_args,
104-
type = 'E'
105-
))
79+
tree = compile(codeString, filename, "exec", _ast.PyCF_ONLY_AST)
80+
w = checker.Checker(tree, filename)
81+
w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
82+
for w in w.messages:
83+
errors.append(dict(
84+
lnum = w.lineno,
85+
col = w.col,
86+
text = w.message % w.message_args,
87+
type = 'E'
88+
))
10689
return errors
10790

10891

0 commit comments

Comments
 (0)