-
-
Notifications
You must be signed in to change notification settings - Fork 23
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: adding depency crashes when not string [APE-959] #103
Conversation
not sure this needs a new test, since every old test fails, but here's a minimal version that replicates our project's setup: #103 |
@@ -199,7 +199,9 @@ def _add_dependencies( | |||
cached_source.parent.mkdir(parents=True, exist_ok=True) | |||
if src.content: | |||
cached_source.touch() | |||
cached_source.write_text(src.content or "") | |||
cached_source.write_text( | |||
src.content if isinstance(src.content, str) else str(src.content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, does this handle .contract
being None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you meant .content
right?
I was just looking at how the manifest is loaded in, parse_file looks like it's deprecated: https://github.com/pydantic/pydantic/blob/0e73e00cbf19ad787c685edf01bb1da7c809a13f/pydantic/main.py#L1086
manifest_data = cached_manifest_file.read_text()
manifest_dict = load_dict(manifest_data)
manifest = PackageManifest.validate(manifest_dict)
sources = manifest.sources
first_source = sources[list(sources.keys())[0]]
print(f"{type(first_source)=}")
first_source.content = None
print(f"{str(first_source.content)=}")
print(f"{first_source.content if isinstance(first_source.content, str) else str(first_source.content)=}")
method1 = str(first_source.content)
method2 = first_source.content if isinstance(first_source.content, str) else str(first_source.content)
print(f"{(method1 == method2)=}")
looks like what I wrote is identical to just casting to str, the above gives:
type(first_source)=<class 'ethpm_types.source.Source'>
str(first_source.content)='None'
first_source.content if isinstance(first_source.content, str) else str(first_source.content)='None'
(method1 == method2)=True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt .content
being None
would happen, since I think that means the compiler would have given None
as output, no? Like on an empty .sol file? I bet it would break before here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah no compiling happens here. tested with a totally empty file (1f14214), and it doesn't pass the if src.content:
on line 200:
Content(__root__={})
if src.content:
print("true")
else:
print("not")
not
I found the culprit pip install eth-ape==0.6.9
pytest -m "not fuzzing"
=============== 43 failed, 11 passed in 22.05s ===============
pip install eth-ape==0.6.8
pytest -m "not fuzzing"
=============== 54 passed in 62.34s (0:01:02) =============== |
narrowed it down to ApeWorX/ape#1337
|
I guess adding tracebacks requires saving manifests with metadata (not just But for manifests you didn't build, they contain just the source code. So It's confusing, because the code already returned the I guess the |
there is already a pr for this here #102 |
What I did
make sure write_test receives a string input.
fixes: #
How I did it
converting only when needed, using an f-string.
How to verify it
see PR in my branch that reverts the fix. lots of tests fail without the fix. functional tests pass with the fix:
Checklist