Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Check whole project on save #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -41,13 +41,24 @@ class Flake8(PythonLinter):
# - E999 SyntaxError

regex = (
r'^.+?:(?P<line>\d+):(?P<col>\d+): '
r'^(?P<filename>(?::\\|[^:])+):(?P<line>\d+):(?P<col>\d+): '
r'(?:(?P<error>(?:F(?:40[24]|8(?:12|2[123]|31))|E(?:11[23]|90[12]|999)))|'
r'(?P<warning>\w+\d+):?) '
r'(?P<message>.*)'
)
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
Expand Down