@@ -41,13 +41,33 @@ 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 should_lint (self , reason = None ):
52+ self .reason = reason
53+ return super ().should_lint (reason )
54+
55+ def cmd (self ):
56+ if (
57+ self .reason in ("on_user_request" , "on_save" )
58+ and self .settings .context .get ('file' , None )
59+ ):
60+ self .tempfile_suffix = '-'
61+ return ('flake8' , '--format' , 'default' , '${args}' , '${xoo:.}' )
62+ else :
63+ return ('flake8' , '--format' , 'default' , '${args}' , '-' )
64+
65+ def split_match (self , match ):
66+ error = super ().split_match (match )
67+ if error .filename == 'stdin' :
68+ error ['filename' ] = ''
69+ return error
70+
5171 def on_stderr (self , stderr ):
5272 # For python 3.7 we actually have the case that flake yields
5373 # FutureWarnings. We just eat those as they're irrelevant here. Note
@@ -75,6 +95,9 @@ def parse_output(self, proc, virtual_view):
7595
7696 filtered_errors = []
7797 for error in errors :
98+ if error is None :
99+ continue
100+
78101 code = error ['code' ]
79102
80103 if ensures_newline and code == 'W292' :
0 commit comments