@@ -77,10 +77,6 @@ def _collect_uninferrable_count(advices: list[LocatedAdvice]):
77
77
return not_computed
78
78
79
79
80
- def _collect_unparseable (advices : list [LocatedAdvice ]):
81
- return list (located_advice for located_advice in advices if located_advice .advice .code == 'parse-error' )
82
-
83
-
84
80
def _print_advices (located_advices : list [LocatedAdvice ]) -> None :
85
81
messages = [f"{ located_advice } \n " for located_advice in located_advices ]
86
82
if os .getenv ("CI" ):
@@ -174,8 +170,16 @@ def _lint_dir(solacc: _SolaccContext, soldir: Path):
174
170
all_files = list (soldir .glob ('**/*.py' )) + list (soldir .glob ('**/*.sql' ))
175
171
solacc .total_count += len (all_files )
176
172
# lint solution
173
+ advices , unparseable_advices = [], []
177
174
start_timestamp = datetime .now (timezone .utc )
178
- advices = list (ctx .local_code_linter .lint_path (soldir ))
175
+ for located_advice in ctx .local_code_linter .lint_path (soldir ):
176
+ print (located_advice ) # defaults to writing to sys.stdout
177
+ advices .append (located_advice )
178
+ if located_advice .advice .code == 'parse-error' :
179
+ unparseable_advices .append (located_advice )
180
+ if located_advice .advice .code == 'import-not-found' :
181
+ missing_import = located_advice .advice .message .split (':' )[1 ].strip ()
182
+ solacc .register_missing_import (missing_import )
179
183
end_timestamp = datetime .now (timezone .utc )
180
184
# record stats
181
185
stats = _SolaccStats (
@@ -188,10 +192,9 @@ def _lint_dir(solacc: _SolaccContext, soldir: Path):
188
192
)
189
193
solacc .stats .append (stats )
190
194
# collect unparseable files
191
- unparseables = _collect_unparseable (advices )
192
- solacc .unparseable_count += len (files_to_skip ) + len (set (advice .path for advice in unparseables ))
195
+ solacc .unparseable_count += len (files_to_skip ) + len (set (advice .path for advice in unparseable_advices ))
193
196
if solacc .unparsed_files_path :
194
- for unparseable in unparseables :
197
+ for unparseable in unparseable_advices :
195
198
logger .error (f"Error during parsing of { unparseable .path } : { unparseable .advice .message } " .replace ("\n " , " " ))
196
199
# populate solacc-unparsed.txt
197
200
with solacc .unparsed_files_path .open (mode = "a" , encoding = "utf-8" ) as f :
@@ -201,9 +204,6 @@ def _lint_dir(solacc: _SolaccContext, soldir: Path):
201
204
path = unparseable .path
202
205
f .write (path .as_posix ())
203
206
f .write ("\n " )
204
- # collect missing imports
205
- for missing_import in _collect_missing_imports (advices ):
206
- solacc .register_missing_import (missing_import )
207
207
# collect uninferrable
208
208
solacc .uninferrable_count += _collect_uninferrable_count (advices )
209
209
# display advices
0 commit comments