Skip to content

Commit

Permalink
fix: imports no go outputsel
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jun 10, 2024
1 parent ff7a19f commit 6154453
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
19 changes: 16 additions & 3 deletions ape_vyper/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,14 @@ def compile(

# Output compiler details.
keys = (
"\n\t".join(sorted([clean_path(Path(x)) for x in src_dict.keys()]))
"\n\t".join(
sorted(
[
clean_path(Path(x))
for x in settings_set.get("outputSelection", {}).keys()
]
)
)
or "No input."
)
log_str = f"Compiling using Vyper compiler '{vyper_version}'.\nInput:\n\t{keys}"
Expand Down Expand Up @@ -968,7 +975,9 @@ def _get_version_map_from_import_map(
for pragma_spec, path_set in source_path_by_version_spec.items():
versions = sorted(list(pragma_spec.filter(self.installed_versions)), reverse=True)
if versions:
_safe_append(version_map, versions[0], path_set)
_safe_append(
version_map, versions[0], {p for p in path_set if p in contract_filepaths}
)

if not self.installed_versions:
# If we have no installed versions by this point, we need to install one.
Expand All @@ -987,7 +996,11 @@ def _get_version_map_from_import_map(
if max_installed_vyper_version is None:
max_installed_vyper_version = max(v for v in self.installed_versions if not v.pre)

_safe_append(version_map, max_installed_vyper_version, source_paths_without_pragma)
_safe_append(
version_map,
max_installed_vyper_version,
{p for p in source_paths_without_pragma if p in contract_filepaths},
)

return version_map

Expand Down
19 changes: 5 additions & 14 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import vvm # type: ignore
from ape.exceptions import CompilerError, ContractLogicError
from ape.utils import get_full_extension
from ethpm_types import ContractType
from packaging.version import Version
from vvm.exceptions import VyperError # type: ignore
Expand Down Expand Up @@ -96,7 +97,9 @@ def test_install_failure(compiler):

def test_get_version_map(project, compiler, all_versions):
vyper_files = [
x for x in project.contracts_folder.iterdir() if x.is_file() and x.suffix == ".vy"
x
for x in project.contracts_folder.iterdir()
if x.is_file() and get_full_extension(x) == ".vy"
]
actual = compiler.get_version_map(vyper_files, project=project)
expected_versions = [Version(v) for v in all_versions]
Expand Down Expand Up @@ -124,14 +127,6 @@ def test_get_version_map(project, compiler, all_versions):
"empty.vy", # empty file still compiles with latest version
"pragma_with_space.vy",
"flatten_me.vy",
# Include interfaces
"ERC20.json",
"Dependency.vy",
"IRegistry.vy",
"IFace.vy",
"IFace2.vy",
"ERC20Detailed.json",
"ISubReverts.vy",
]

# Add the 0.3.10 contracts.
Expand Down Expand Up @@ -160,11 +155,7 @@ def test_get_version_map(project, compiler, all_versions):

# Vyper 0.4.0 assertions.
actual4 = {x.name for x in actual[VERSION_04]}
expected4 = {
"zero_four_module.vy",
"IFaceZeroFour.vyi",
"zero_four.vy",
}
expected4 = {"zero_four_module.vy", "zero_four.vy"}
assert actual4 == expected4


Expand Down

0 comments on commit 6154453

Please sign in to comment.