Skip to content

Commit

Permalink
fix: attempt paths fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 27, 2024
1 parent 02b3fb4 commit 2a8780f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
1 change: 1 addition & 0 deletions ape_vyper/compiler/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 4 additions & 15 deletions ape_vyper/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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)
Expand All @@ -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]))
Expand All @@ -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]
Expand Down

0 comments on commit 2a8780f

Please sign in to comment.