-
-
Notifications
You must be signed in to change notification settings - Fork 836
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[lang]: disallow absolute relative imports #4268
fix[lang]: disallow absolute relative imports #4268
Conversation
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.
yes, i think poke_search_paths is probably dead now. can you check? if so, let's remove it!
vyper/semantics/analysis/module.py
Outdated
@@ -789,11 +789,7 @@ def _add_import( | |||
# load an InterfaceT or ModuleInfo from an import. | |||
# raises FileNotFoundError | |||
def _load_import(self, node: vy_ast.VyperNode, level: int, module_str: str, alias: str) -> Any: |
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 guess we can fuse load_import_helper right?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4268 +/- ##
==========================================
- Coverage 91.12% 88.46% -2.67%
==========================================
Files 115 115
Lines 16235 16236 +1
Branches 2732 2733 +1
==========================================
- Hits 14794 14363 -431
- Misses 1004 1352 +348
- Partials 437 521 +84 ☔ View full report in Codecov by Sentry. |
@charles-cooper, have you considered the concept of packages? because we don't have it, we allow relative imports that can point even outside the project's directory |
i tried to create an output bundle (vyper -f archive) with this setup and it led to compiler panic
|
@sandbubbles please resolve merge conflicts |
vyper/semantics/analysis/imports.py
Outdated
res = self.input_bundle.load_file(path) | ||
|
||
if level != 0: | ||
self.input_bundle.search_paths += [current_search_path] |
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.
self.input_bundle.search_paths += [current_search_path] | |
self.input_bundle.search_paths.append(current_search_path) |
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.
this is kind of weird actually because on line 221, we already set search_paths to [current_search_path]
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 think the issue is we need to set it temporarily to only one path, but then we need to add it to search paths in case there is an absolute import that uses it
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.
isn't that handled in the recursion by line 221?
https://github.com/vyperlang/vyper/pull/4268/files/c91f13e870bce8001eeec83dd96b8320c53d4343#diff-dc7dbf75948a3fce0db2cfa0fa819c964a534604d06f72ae88d18e3e3eef78b6R221
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 pushed a clean up in a140226
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 must have though that example such as the following should work (but its what we were fixing in the first place).
#a.vy
from .subdir import b
and
#b.vy
from subdir.subsubdir import c
This should be ready for rereview |
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.
lgtm, thank you
### 🕓 Changelog This commit updates the version `pragma`s in all Vyper source files to target the latest `master` version `v0.4.1b4`, aligning with the release of Vyper's newest beta version, [`v0.4.1b3`](https://github.com/vyperlang/vyper/releases/tag/v0.4.1b3). Additionally, this PR addresses a disallowed pattern in the `IERC1155MetadataURI.vyi` interface definition by fixing the use of absolute relative imports, which are prohibited in Vyper since PR [#4268](vyperlang/vyper#4268). --------- Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
What I did
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture