@@ -30,57 +30,58 @@ def pylsp_settings():
30
30
31
31
@hookimpl
32
32
def pylsp_lint (workspace , document ):
33
- config = workspace ._config
34
- settings = config .plugin_settings ('flake8' , document_path = document .path )
35
- log .debug ("Got flake8 settings: %s" , settings )
36
-
37
- ignores = settings .get ("ignore" , [])
38
- per_file_ignores = settings .get ("perFileIgnores" )
39
-
40
- if per_file_ignores :
41
- prev_file_pat = None
42
- for path in per_file_ignores :
43
- try :
44
- file_pat , errors = path .split (":" )
45
- prev_file_pat = file_pat
46
- except ValueError :
47
- # It's legal to just specify another error type for the same
48
- # file pattern:
49
- if prev_file_pat is None :
50
- log .warning (
51
- "skipping a Per-file-ignore with no file pattern" )
52
- continue
53
- file_pat = prev_file_pat
54
- errors = path
55
- if PurePath (document .path ).match (file_pat ):
56
- ignores .extend (errors .split ("," ))
57
-
58
- opts = {
59
- 'config' : settings .get ('config' ),
60
- 'exclude' : settings .get ('exclude' ),
61
- 'filename' : settings .get ('filename' ),
62
- 'hang-closing' : settings .get ('hangClosing' ),
63
- 'ignore' : ignores or None ,
64
- 'max-complexity' : settings .get ('maxComplexity' ),
65
- 'max-line-length' : settings .get ('maxLineLength' ),
66
- 'indent-size' : settings .get ('indentSize' ),
67
- 'select' : settings .get ('select' ),
68
- }
69
-
70
- # flake takes only absolute path to the config. So we should check and
71
- # convert if necessary
72
- if opts .get ('config' ) and not os .path .isabs (opts .get ('config' )):
73
- opts ['config' ] = os .path .abspath (os .path .expanduser (os .path .expandvars (
74
- opts .get ('config' )
75
- )))
76
- log .debug ("using flake8 with config: %s" , opts ['config' ])
77
-
78
- # Call the flake8 utility then parse diagnostics from stdout
79
- flake8_executable = settings .get ('executable' , 'flake8' )
80
-
81
- args = build_args (opts )
82
- output = run_flake8 (flake8_executable , args , document )
83
- return parse_stdout (document , output )
33
+ with workspace .report_progress ("lint: flake8" ):
34
+ config = workspace ._config
35
+ settings = config .plugin_settings ('flake8' , document_path = document .path )
36
+ log .debug ("Got flake8 settings: %s" , settings )
37
+
38
+ ignores = settings .get ("ignore" , [])
39
+ per_file_ignores = settings .get ("perFileIgnores" )
40
+
41
+ if per_file_ignores :
42
+ prev_file_pat = None
43
+ for path in per_file_ignores :
44
+ try :
45
+ file_pat , errors = path .split (":" )
46
+ prev_file_pat = file_pat
47
+ except ValueError :
48
+ # It's legal to just specify another error type for the same
49
+ # file pattern:
50
+ if prev_file_pat is None :
51
+ log .warning (
52
+ "skipping a Per-file-ignore with no file pattern" )
53
+ continue
54
+ file_pat = prev_file_pat
55
+ errors = path
56
+ if PurePath (document .path ).match (file_pat ):
57
+ ignores .extend (errors .split ("," ))
58
+
59
+ opts = {
60
+ 'config' : settings .get ('config' ),
61
+ 'exclude' : settings .get ('exclude' ),
62
+ 'filename' : settings .get ('filename' ),
63
+ 'hang-closing' : settings .get ('hangClosing' ),
64
+ 'ignore' : ignores or None ,
65
+ 'max-complexity' : settings .get ('maxComplexity' ),
66
+ 'max-line-length' : settings .get ('maxLineLength' ),
67
+ 'indent-size' : settings .get ('indentSize' ),
68
+ 'select' : settings .get ('select' ),
69
+ }
70
+
71
+ # flake takes only absolute path to the config. So we should check and
72
+ # convert if necessary
73
+ if opts .get ('config' ) and not os .path .isabs (opts .get ('config' )):
74
+ opts ['config' ] = os .path .abspath (os .path .expanduser (os .path .expandvars (
75
+ opts .get ('config' )
76
+ )))
77
+ log .debug ("using flake8 with config: %s" , opts ['config' ])
78
+
79
+ # Call the flake8 utility then parse diagnostics from stdout
80
+ flake8_executable = settings .get ('executable' , 'flake8' )
81
+
82
+ args = build_args (opts )
83
+ output = run_flake8 (flake8_executable , args , document )
84
+ return parse_stdout (document , output )
84
85
85
86
86
87
def run_flake8 (flake8_executable , args , document ):
0 commit comments