diff --git a/ape_vyper/compiler/api.py b/ape_vyper/compiler/api.py index ff8cce9..a2956a6 100644 --- a/ape_vyper/compiler/api.py +++ b/ape_vyper/compiler/api.py @@ -378,6 +378,7 @@ def get_version_map( ) -> dict[Version, set[Path]]: pm = project or self.local_project import_map = self._import_resolver.get_imports(pm, contract_filepaths) + import_map.paths = contract_filepaths return self._get_version_map_from_import_map(contract_filepaths, import_map, project=pm) def _get_version_map_from_import_map( diff --git a/ape_vyper/imports.py b/ape_vyper/imports.py index c18f2bc..c2f7ff9 100644 --- a/ape_vyper/imports.py +++ b/ape_vyper/imports.py @@ -264,7 +264,7 @@ def __init__(self, project: ProjectManager, paths: list[Path]): # Even though we build up mappings of all sources, as may be referenced # later on and that prevents re-calculating over again, we only # "show" the items requested. - self._request_view: list[Path] = paths + self.paths: list[Path] = paths def __getitem__(self, item: Union[str, Path], *args, **kwargs) -> list[Import]: if isinstance(item, str) or not item.is_absolute(): @@ -294,7 +294,7 @@ def keys(self) -> list[Path]: # type: ignore result = [] keys = sorted(list(super().keys())) for path in keys: - if path not in self._request_view: + if path not in self.paths: continue result.append(path) @@ -311,7 +311,7 @@ def values(self) -> list[list[Import]]: # type: ignore def items(self) -> list[tuple[Path, list[Import]]]: # type: ignore result = [] for path in self.keys(): # sorted - if path not in self._request_view: + if path not in self.paths: continue result.append((path, self[path])) @@ -334,21 +334,10 @@ def get_imports( contract_filepaths: Iterable[Path], ) -> ImportMap: paths = list(contract_filepaths) - reset_view = None if project.project_id not in self._projects: self._projects[project.project_id] = ImportMap(project, paths) - else: - # Change the items we "view". Some (or all) may need to be added as well. - reset_view = self._projects[project.project_id]._request_view - self._projects[project.project_id]._request_view = paths - - try: - import_map = self._get_imports(paths, project) - finally: - if reset_view is not None: - self._projects[project.project_id]._request_view = reset_view - return import_map + return self._get_imports(paths, project) def _get_imports(self, paths: list[Path], project: ProjectManager) -> ImportMap: import_map = self._projects[project.project_id]