Skip to content

Commit 3cc6d6f

Browse files
committed
Check whole folder on save (if desired)
1 parent 43f80d6 commit 3cc6d6f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

linter.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
class Flake8(PythonLinter):
1515

16-
cmd = ('flake8', '--format', 'default', '${args}', '-')
1716
defaults = {
1817
'selector': 'source.python',
1918

2019
# Ignore codes Sublime can auto-fix
21-
'ignore_fixables': True
20+
'ignore_fixables': True,
21+
'check_project_on_save': True,
2222
}
2323

2424
# The following regex marks these pyflakes and pep8 codes as errors.
@@ -41,13 +41,24 @@ class Flake8(PythonLinter):
4141
# - E999 SyntaxError
4242

4343
regex = (
44-
r'^.+?:(?P<line>\d+):(?P<col>\d+): '
44+
r'^(?P<filename>(?::\\|[^:])+):(?P<line>\d+):(?P<col>\d+): '
4545
r'(?:(?P<error>(?:F(?:40[24]|8(?:12|2[123]|31))|E(?:11[23]|90[12]|999)))|'
4646
r'(?P<warning>\w+\d+):?) '
4747
r'(?P<message>.*)'
4848
)
4949
multiline = True
5050

51+
def cmd(self):
52+
if (
53+
self.settings.get('check_project_on_save')
54+
and self.context.get('reason') in ('on_user_request', 'on_save')
55+
and self.context.get('file')
56+
):
57+
self.tempfile_suffix = '-'
58+
return ('flake8', '--format', 'default', '${args}', '${xoo:.}')
59+
else:
60+
return ('flake8', '--format', 'default', '${args}', '-')
61+
5162
def on_stderr(self, stderr):
5263
# For python 3.7 we actually have the case that flake yields
5364
# FutureWarnings. We just eat those as they're irrelevant here. Note

0 commit comments

Comments
 (0)