Skip to content

Commit 2ac11ee

Browse files
committed
- Fix bug (missing add_source_files)
- Fix linters
1 parent 1396844 commit 2ac11ee

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

crytic_compile/crytic_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def compile_all(target: str, **kwargs: str) -> List[CryticCompile]:
623623
**kwargs: optional arguments. Used: "solc_standard_json"
624624
625625
Raises:
626-
ValueError: If the target could not be compiled
626+
NotImplementedError: If the target could not be compiled
627627
628628
Returns:
629629
List[CryticCompile]: Returns a list of CryticCompile instances for all compilations which occurred.

crytic_compile/platform/solc_standard_json.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,15 @@ def add_source_file(self, file_path: str) -> None:
405405
"""
406406
add_source_file(self._json, file_path)
407407

408+
def add_source_files(self, files_path: List[str]) -> None:
409+
"""Append files
410+
411+
Args:
412+
files_path (List[str]): files to append
413+
"""
414+
for file_path in files_path:
415+
add_source_file(self._json, file_path)
416+
408417
def add_remapping(self, remapping: str) -> None:
409418
"""Append our remappings
410419

crytic_compile/platform/vyper.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import json
55
import logging
66
import os
7-
import subprocess
87
import shutil
8+
import subprocess
99
from pathlib import Path
1010
from typing import TYPE_CHECKING, Dict, List, Optional
1111

@@ -15,7 +15,6 @@
1515
from crytic_compile.platform.exceptions import InvalidCompilation
1616
from crytic_compile.platform.types import Type
1717
from crytic_compile.utils.naming import convert_filename
18-
from crytic_compile.utils.subprocess import run
1918

2019
# Handle cycle
2120
from crytic_compile.utils.natspec import Natspec
@@ -112,8 +111,18 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
112111
source_unit.ast = ast
113112

114113
def add_source_files(self, file_paths: List[str]) -> None:
114+
"""
115+
Append files
116+
117+
Args:
118+
file_paths (List[str]): files to append
119+
120+
Returns:
121+
122+
"""
123+
115124
for file_path in file_paths:
116-
with open(file_path, "r") as f:
125+
with open(file_path, "r", encoding="utf8") as f:
117126
self.standard_json_input["sources"][file_path] = {
118127
"content": f.read(),
119128
}
@@ -163,18 +172,14 @@ def _guessed_tests(self) -> List[str]:
163172

164173

165174
def _run_vyper_standard_json(
166-
standard_json_input: Dict,
167-
vyper: str,
168-
env: Optional[Dict] = None,
169-
working_dir: Optional[str] = None,
175+
standard_json_input: Dict, vyper: str, env: Optional[Dict] = None
170176
) -> Dict:
171177
"""Run vyper and write compilation output to a file
172178
173179
Args:
174180
standard_json_input (Dict): Dict containing the vyper standard json input
175181
vyper (str): vyper binary
176182
env (Optional[Dict], optional): Environment variables. Defaults to None.
177-
working_dir (Optional[str], optional): Working directory. Defaults to None.
178183
179184
Raises:
180185
InvalidCompilation: If vyper failed to run
@@ -194,7 +199,7 @@ def _run_vyper_standard_json(
194199
) as process:
195200

196201
stdout_b, stderr_b = process.communicate(json.dumps(standard_json_input).encode("utf-8"))
197-
stdout, stderr = (
202+
stdout, _stderr = (
198203
stdout_b.decode(),
199204
stderr_b.decode(errors="backslashreplace"),
200205
) # convert bytestrings to unicode strings

0 commit comments

Comments
 (0)