-
-
Notifications
You must be signed in to change notification settings - Fork 766
Expand file tree
/
Copy pathlint.py
More file actions
49 lines (36 loc) · 1.24 KB
/
lint.py
File metadata and controls
49 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
""" Pylama integration. """
import vim # noqa
from .utils import pymode_message, silence_stderr
import os.path
def code_check():
""" Run pylama and check current file. """
from .pylama.main import parse_options
from .pylama.tasks import check_path
import json
b = vim.current.buffer
root = vim.eval('getcwd()')
linters = vim.eval('g:pymode_lint_checkers')
ignore = vim.eval('g:pymode_lint_ignore')
select = vim.eval('g:pymode_lint_select')
options = parse_options(
ignore=ignore, select=select, linters=linters)
path = b.name
if root:
path = os.path.relpath(path, root)
if getattr(options, 'skip', None) and any(p.match(path) for p in options.skip): # noqa
pymode_message('Skip code checking.')
vim.command('return')
return False
with silence_stderr():
errors = check_path(path, options=options)
sort_rules = vim.eval('g:pymode_lint_sort')
def sort(e):
try:
print(e.get('type'))
return sort_rules.index(e.get('type'))
except ValueError:
return 999
if sort_rules:
print(sort_rules)
errors = sorted(errors, key=sort)
vim.command('call setqflist(%s)' % json.dumps(errors))