@@ -77,10 +77,6 @@ def _collect_uninferrable_count(advices: list[LocatedAdvice]):
7777 return not_computed
7878
7979
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-
8480def _print_advices (located_advices : list [LocatedAdvice ]) -> None :
8581 messages = [f"{ located_advice } \n " for located_advice in located_advices ]
8682 if os .getenv ("CI" ):
@@ -174,8 +170,16 @@ def _lint_dir(solacc: _SolaccContext, soldir: Path):
174170 all_files = list (soldir .glob ('**/*.py' )) + list (soldir .glob ('**/*.sql' ))
175171 solacc .total_count += len (all_files )
176172 # lint solution
173+ advices , unparseable_advices = [], []
177174 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 )
179183 end_timestamp = datetime .now (timezone .utc )
180184 # record stats
181185 stats = _SolaccStats (
@@ -188,10 +192,9 @@ def _lint_dir(solacc: _SolaccContext, soldir: Path):
188192 )
189193 solacc .stats .append (stats )
190194 # 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 ))
193196 if solacc .unparsed_files_path :
194- for unparseable in unparseables :
197+ for unparseable in unparseable_advices :
195198 logger .error (f"Error during parsing of { unparseable .path } : { unparseable .advice .message } " .replace ("\n " , " " ))
196199 # populate solacc-unparsed.txt
197200 with solacc .unparsed_files_path .open (mode = "a" , encoding = "utf-8" ) as f :
@@ -201,9 +204,6 @@ def _lint_dir(solacc: _SolaccContext, soldir: Path):
201204 path = unparseable .path
202205 f .write (path .as_posix ())
203206 f .write ("\n " )
204- # collect missing imports
205- for missing_import in _collect_missing_imports (advices ):
206- solacc .register_missing_import (missing_import )
207207 # collect uninferrable
208208 solacc .uninferrable_count += _collect_uninferrable_count (advices )
209209 # display advices
0 commit comments