Skip to content

Commit

Permalink
fix some typing/lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Oct 29, 2023
1 parent a2b21b7 commit 38865ad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions vyper/cli/vyper_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def compile_files(

contract_sources: ContractCodes = dict()
for file_name in input_files:
file_path = Path(file_name)
contract_sources[file_path] = input_bundle.load_file(Path(file_path))

storage_layouts = dict()
Expand Down
12 changes: 6 additions & 6 deletions vyper/cli/vyper_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ def get_compilation_targets(input_dict: dict) -> ContractCodes:
f"Calculated keccak of '{path}' does not match keccak given in input JSON"
)
if path in ret:
raise JSONError(f"Contract namespace collision: {key}")
raise JSONError(f"Contract namespace collision: {path}")

ret[path] = value["content"]
ret[path] = value

for path, value in input_dict.get("interfaces", {}).items():
if key in interface_sources:
raise JSONError(f"Interface namespace collision: {key}")
if path in ret:
raise JSONError(f"Interface namespace collision: {path}")

ret[path] = value
ret[path] = {"content": value}

return ret

Expand Down Expand Up @@ -208,7 +208,7 @@ def get_input_dict_output_formats(input_dict: Dict, contract_sources: ContractCo
if path == "*":
output_keys = list(contract_sources.keys())
else:
output_keys = [_standardize_path(path)]
output_keys = [Path(path)]
if output_keys[0] not in contract_sources:
raise JSONError(f"outputSelection references unknown contract '{output_keys[0]}'")

Expand Down
15 changes: 8 additions & 7 deletions vyper/compiler/input_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def _load_from_path(self, path: Path) -> CompilerInput:
source_id = super()._generate_source_id(path)
return FileInput(source_id, path, code)


# fake filesystem for JSON inputs. takes a base path, and `load_file()`
# "reads" the file from the JSON input. Note that this input bundle type
# never actually interacts with the filesystem -- it is guaranteed to be pure!
Expand All @@ -107,20 +108,20 @@ class JSONInputBundle(InputBundle):

def _load_from_path(self, path: PurePath) -> CompilerInput:
try:
contents = self.input_json[path]
value = self.input_json[path]
except KeyError:
raise _NotFound(path)

source_id = super()._generate_source_id(path)

if isinstance(contents, str):
return FileInput(source_id, path, code)
if "content" in value:
return FileInput(source_id, path, value["content"])

if "abi" in contents:
return ABIInput(source_id, path, contents["abi"])
if "abi" in value:
return ABIInput(source_id, path, value["abi"])

if isinstance(contents, list):
return ABIInput(source_id, path, contents)
if isinstance(value, list):
return ABIInput(source_id, path, value)

# TODO: ethPM support
# if isinstance(contents, dict) and "contractTypes" in contents:
Expand Down
7 changes: 3 additions & 4 deletions vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import vyper.builtins.interfaces
from vyper import ast as vy_ast
from vyper.compiler.input_bundle import ABIInput, CompilerInput, InputBundle, VyFile
from vyper.compiler.input_bundle import InputBundle
from vyper.evm.opcodes import version_check
from vyper.exceptions import (
CallViolation,
CompilerPanic,
ExceptionList,
InvalidLiteral,
InvalidType,
Expand Down Expand Up @@ -341,8 +340,8 @@ def _load_import(self, level: int, module: str) -> InterfaceT:
path = _import_to_path(level, module)
try:
file = self.input_bundle.load_file(path.with_suffix(".vy"))
ast = vy_ast.parse_to_ast(file.source_code, contract_name=file.path)
InterfaceT.from_ast(interface_ast)
interface_ast = vy_ast.parse_to_ast(file.source_code, contract_name=file.path)
return InterfaceT.from_ast(interface_ast)
except FileNotFoundError:
file = self.input_bundle.load_file(path.with_suffix(".json"))
abi = json.loads(file.source_code)
Expand Down

0 comments on commit 38865ad

Please sign in to comment.