From 3cc6d6fd369bffe6805386c77a9dd62b1827b7f8 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Tue, 2 Aug 2022 01:30:27 +0200 Subject: [PATCH] Check whole folder on save (if desired) --- linter.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/linter.py b/linter.py index 6c587f2..d9913a4 100644 --- a/linter.py +++ b/linter.py @@ -13,12 +13,12 @@ class Flake8(PythonLinter): - cmd = ('flake8', '--format', 'default', '${args}', '-') defaults = { 'selector': 'source.python', # Ignore codes Sublime can auto-fix - 'ignore_fixables': True + 'ignore_fixables': True, + 'check_project_on_save': True, } # The following regex marks these pyflakes and pep8 codes as errors. @@ -41,13 +41,24 @@ class Flake8(PythonLinter): # - E999 SyntaxError regex = ( - r'^.+?:(?P\d+):(?P\d+): ' + r'^(?P(?::\\|[^:])+):(?P\d+):(?P\d+): ' r'(?:(?P(?:F(?:40[24]|8(?:12|2[123]|31))|E(?:11[23]|90[12]|999)))|' r'(?P\w+\d+):?) ' r'(?P.*)' ) multiline = True + def cmd(self): + if ( + self.settings.get('check_project_on_save') + and self.context.get('reason') in ('on_user_request', 'on_save') + and self.context.get('file') + ): + self.tempfile_suffix = '-' + return ('flake8', '--format', 'default', '${args}', '${xoo:.}') + else: + return ('flake8', '--format', 'default', '${args}', '-') + def on_stderr(self, stderr): # For python 3.7 we actually have the case that flake yields # FutureWarnings. We just eat those as they're irrelevant here. Note