Skip to content

Commit 147846c

Browse files
committed
Fix lint
1 parent 22d9288 commit 147846c

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

pymode/lint.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def code_check():
1616
from pylama.main import parse_options
1717
from pylama.tasks import check_path
1818

19+
if not env.curbuf.name:
20+
env.stop()
21+
return False
22+
1923
options = parse_options(
2024
ignore=env.var('g:pymode_lint_ignore'),
2125
select=env.var('g:pymode_lint_select'),
@@ -36,7 +40,7 @@ def code_check():
3640
LOGGER.setLevel(logging.DEBUG)
3741

3842
with silence_stderr():
39-
errors = check_path(path, options=options, code=env.source)
43+
errors = check_path(path, options=options, code='\n'.join(env.curbuf))
4044

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

t/lint.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,17 @@ describe 'pymode check code'
1414
Expect g:pymode_lint == 1
1515
end
1616

17+
it 'lint code'
18+
put =['# coding: utf-8', 'call_unknown_function()']
19+
PymodeLint
20+
Expect getloclist(0) == []
21+
end
22+
23+
it 'lint code'
24+
e t/test.py
25+
PymodeLint
26+
Expect getloclist(0) == [{'lnum': 6, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'W0612 local variable "unused" is assigned to but never used [pyflakes]'}, {'lnum': 8, 'bufnr': 1, 'col': 0, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': 'E', 'pattern': '', 'text': 'E0602 undefined name "unknown" [pyflakes]'}]
27+
end
28+
1729
end
1830

t/test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
5+
def main():
6+
unused = 1
7+
8+
unknown()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy