From b5c26f0aff4685cc3a73e583f24dd9cf5ffa3fbc Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Fri, 27 Sep 2024 16:52:04 -0500 Subject: [PATCH] fix: cache issue with imports --- ape_vyper/compiler/api.py | 6 +++--- ape_vyper/imports.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ape_vyper/compiler/api.py b/ape_vyper/compiler/api.py index a2956a6..e50f70f 100644 --- a/ape_vyper/compiler/api.py +++ b/ape_vyper/compiler/api.py @@ -83,7 +83,7 @@ def get_imports( project: Optional[ProjectManager] = None, ) -> dict[str, list[str]]: pm = project or self.local_project - imports = self._import_resolver.get_imports(pm, contract_filepaths) + imports = self._import_resolver.get_imports(pm, contract_filepaths, use_cache=False) return { f"{get_relative_path(p.absolute(), pm.path)}": [imp.source_id for imp in import_ls] for p, import_ls in imports.items() @@ -250,7 +250,7 @@ def compile( self.compiler_settings = {**self.compiler_settings, **(settings or {})} contract_types: list[ContractType] = [] - import_map = self._import_resolver.get_imports(pm, contract_filepaths) + import_map = self._import_resolver.get_imports(pm, contract_filepaths, use_cache=False) config = self.get_config(pm) version_map = self._get_version_map_from_import_map( contract_filepaths, @@ -377,7 +377,7 @@ def get_version_map( project: Optional[ProjectManager] = None, ) -> dict[Version, set[Path]]: pm = project or self.local_project - import_map = self._import_resolver.get_imports(pm, contract_filepaths) + import_map = self._import_resolver.get_imports(pm, contract_filepaths, use_cache=False) import_map.paths = contract_filepaths return self._get_version_map_from_import_map(contract_filepaths, import_map, project=pm) diff --git a/ape_vyper/imports.py b/ape_vyper/imports.py index 24d99e9..276c604 100644 --- a/ape_vyper/imports.py +++ b/ape_vyper/imports.py @@ -332,9 +332,10 @@ def get_imports( self, project: ProjectManager, contract_filepaths: Iterable[Path], + use_cache: bool = True, ) -> ImportMap: paths = list(contract_filepaths) - if project.project_id not in self._projects: + if project.project_id not in self._projects or not use_cache: self._projects[project.project_id] = ImportMap(project, paths) return self._get_imports(paths, project)