Skip to content

Commit 72228bb

Browse files
small refactor
1 parent 7add8ce commit 72228bb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

vyper/compiler/input_bundle.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ def _load_from_path(self, resolved_path: PurePath, original_path: PurePath) -> C
243243
# input bundle for vyper archives. similar to JSONInputBundle, but takes
244244
# a zipfile as input.
245245
class ZipInputBundle(InputBundle):
246+
SOURCES_DIRECTORY = PurePath("sources")
247+
246248
def __init__(self, archive: "ZipFile"):
247249
assert archive.testzip() is None
248250
self.archive = archive
@@ -259,7 +261,7 @@ def _load_from_path(self, resolved_path: PurePath, original_path: PurePath) -> C
259261
# zipfile.BadZipFile: File is not a zip file
260262

261263
try:
262-
p = PurePath("sources") / resolved_path
264+
p = self.SOURCES_DIRECTORY / resolved_path
263265
value = self.archive.read(p.as_posix()).decode("utf-8")
264266
except KeyError:
265267
# zipfile literally raises KeyError if the file is not there

vyper/compiler/output_bundle.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pathlib import PurePath
88
from typing import Optional
99

10-
from vyper.compiler.input_bundle import CompilerInput, _NotFound
10+
from vyper.compiler.input_bundle import CompilerInput, ZipInputBundle, _NotFound
1111
from vyper.compiler.phases import CompilerData
1212
from vyper.compiler.settings import Settings
1313
from vyper.exceptions import CompilerPanic
@@ -252,7 +252,8 @@ def __del__(self):
252252

253253
def write_sources(self, sources: dict[str, CompilerInput]):
254254
for path, c in sources.items():
255-
path = f"sources/{_anonymize(path)}"
255+
prefix = ZipInputBundle.SOURCES_DIRECTORY
256+
path = str(prefix / _anonymize(path))
256257
self.archive.writestr(path, c.contents)
257258

258259
def write_storage_layout_overrides(

0 commit comments

Comments
 (0)