Skip to content

Commit

Permalink
refactor out get_settings function
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Sep 1, 2024
1 parent e0fa842 commit cd4ae4a
Showing 1 changed file with 12 additions and 8 deletions.
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", None)
experimental_codegen = input_dict["settings"].get("experimentalCodegen")

Check warning on line 256 in vyper/cli/vyper_json.py

View check run for this annotation

Codecov / codecov/patch

vyper/cli/vyper_json.py#L256

Added line #L256 was not covered by tests
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(

Check warning on line 269 in vyper/cli/vyper_json.py

View check run for this annotation

Codecov / codecov/patch

vyper/cli/vyper_json.py#L269

Added line #L269 was not covered by tests
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.")

Check warning on line 278 in vyper/cli/vyper_json.py

View check run for this annotation

Codecov / codecov/patch

vyper/cli/vyper_json.py#L278

Added line #L278 was not covered by tests

settings = get_settings(input_dict)

Check warning on line 280 in vyper/cli/vyper_json.py

View check run for this annotation

Codecov / codecov/patch

vyper/cli/vyper_json.py#L280

Added line #L280 was not covered by tests

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

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

0 comments on commit cd4ae4a

Please sign in to comment.