2121import os
2222import os .path as p
2323from threading import Lock
24- from typing import Any , Dict , FrozenSet , Iterable , Optional , Set , Tuple
24+ from typing import Any , Dict , FrozenSet , Iterable , Mapping , Optional , Set , Tuple
2525
2626from hdl_checker .database import Database # pylint: disable=unused-import
2727from hdl_checker .diagnostics import CheckerDiagnostic , DiagType
@@ -202,18 +202,21 @@ def _getRebuilds(self, path, line, library):
202202 Gets info on what should be rebuilt to satisfy the builder
203203 """
204204 try :
205- parse_results = self ._searchForRebuilds (line )
205+ parse_results = self ._searchForRebuilds (path , line )
206206 except NotImplementedError : # pragma: no cover
207207 return set ()
208208
209209 rebuilds = set () # type: Set[RebuildInfo]
210210 for rebuild in parse_results :
211- unit_type = rebuild .get ("unit_type" , None ) # type: str
212- library_name = rebuild .get ("library_name" , None ) # type: str
213- unit_name = rebuild .get ("unit_name" , None ) # type: str
214- rebuild_path = rebuild .get ("rebuild_path" , None ) # type: str
211+ unit_type = rebuild .get ("unit_type" , None ) # type: Optional[ str]
212+ library_name = rebuild .get ("library_name" , None ) # type: Optional[ str]
213+ unit_name = rebuild .get ("unit_name" , None ) # type: Optional[ str]
214+ rebuild_path = rebuild .get ("rebuild_path" , None ) # type: Optional[ str]
215215
216- if None not in (unit_type , unit_name ):
216+ if library_name == "work" :
217+ library_name = library .name
218+
219+ if unit_name is not None and unit_type is not None :
217220 for dependency in self ._database .getDependenciesByPath (path ):
218221 if dependency .name .name == rebuild ["unit_name" ]:
219222 rebuilds .add (
@@ -222,9 +225,7 @@ def _getRebuilds(self, path, line, library):
222225 )
223226 )
224227 break
225- elif None not in (library_name , unit_name ):
226- if library_name == "work" :
227- library_name = library .name
228+ elif library_name is not None and unit_name is not None :
228229 rebuilds .add (
229230 RebuildLibraryUnit (Identifier (unit_name ), Identifier (library_name ))
230231 )
@@ -237,8 +238,8 @@ def _getRebuilds(self, path, line, library):
237238
238239 return rebuilds
239240
240- def _searchForRebuilds (self , line ): # pragma: no cover
241- # type: (... ) -> Any
241+ def _searchForRebuilds (self , path , line ): # pragma: no cover
242+ # type: (Path, str ) -> Iterable[Mapping[str, str]]
242243 """
243244 Finds units that the builders is telling us to rebuild
244245 """
0 commit comments