Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix[tool]: keep experimentalCodegen blank in standard json input #4216

Merged
13 changes: 12 additions & 1 deletion tests/unit/cli/vyper_json/test_get_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from vyper.cli.vyper_json import get_evm_version
from vyper.cli.vyper_json import get_evm_version, get_settings
from vyper.exceptions import JSONError


Expand Down Expand Up @@ -30,3 +30,14 @@ def test_early_evm(evm_version_str):
@pytest.mark.parametrize("evm_version_str", ["london", "paris", "shanghai", "cancun"])
def test_valid_evm(evm_version_str):
assert evm_version_str == get_evm_version({"settings": {"evmVersion": evm_version_str}})


def test_experimental_codegen_settings():
input_json = {"settings": {}}
assert get_settings(input_json).experimental_codegen is None

input_json = {"settings": {"experimentalCodegen": True}}
assert get_settings(input_json).experimental_codegen is True

input_json = {"settings": {"experimentalCodegen": False}}
assert get_settings(input_json).experimental_codegen is False
20 changes: 12 additions & 8 deletions vyper/cli/vyper_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,11 @@ def get_search_paths(input_dict: dict) -> list[PurePath]:
return [PurePath(p) for p in ret]


def compile_from_input_dict(
input_dict: dict, exc_handler: Callable = exc_handler_raises
) -> tuple[dict, dict]:
if input_dict["language"] != "Vyper":
raise JSONError(f"Invalid language '{input_dict['language']}' - Only Vyper is supported.")

def get_settings(input_dict: dict) -> Settings:
evm_version = get_evm_version(input_dict)

optimize = input_dict["settings"].get("optimize")
experimental_codegen = input_dict["settings"].get("experimentalCodegen", False)
experimental_codegen = input_dict["settings"].get("experimentalCodegen")
if isinstance(optimize, bool):
# bool optimization level for backwards compatibility
warnings.warn(
Expand All @@ -271,10 +266,19 @@ def compile_from_input_dict(
else:
assert optimize is None

settings = Settings(
return Settings(
evm_version=evm_version, optimize=optimize, experimental_codegen=experimental_codegen
)


def compile_from_input_dict(
input_dict: dict, exc_handler: Callable = exc_handler_raises
) -> tuple[dict, dict]:
if input_dict["language"] != "Vyper":
raise JSONError(f"Invalid language '{input_dict['language']}' - Only Vyper is supported.")

settings = get_settings(input_dict)

no_bytecode_metadata = not input_dict["settings"].get("bytecodeMetadata", True)

integrity = input_dict.get("integrity")
Expand Down
Loading