-
-
Notifications
You must be signed in to change notification settings - Fork 871
feat[lang]!: move sqrt to new stdlib math module
#4520
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
feat[lang]!: move sqrt to new stdlib math module
#4520
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4520 +/- ##
==========================================
- Coverage 92.71% 92.63% -0.09%
==========================================
Files 123 122 -1
Lines 17546 17518 -28
Branches 2977 2976 -1
==========================================
- Hits 16268 16228 -40
- Misses 879 892 +13
+ Partials 399 398 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
addresses the |
| ZeroDivisionException, | ||
| ) | ||
| from vyper.semantics.analysis.base import Modifiability, VarInfo | ||
| from vyper.semantics.analysis.base import Modifiability |
Check notice
Code scanning / CodeQL
Cyclic import Note
vyper.semantics.analysis.base
vyper/semantics/analysis/imports.py
Outdated
| remapped_module = module_str | ||
| if remapped_module.startswith("ethereum.ercs"): | ||
| if is_erc_interface: | ||
| remapped_module = remapped_module.removeprefix("ethereum.ercs") |
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.
maybe we should physically move these to the stdlib/ directory
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.
(to fuse the two branches)
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.
won't it still require a condition?
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.
updated the remapping logic a bit to use a dict: 828d3ea
|
|
||
| def test_sqrt_literal(get_contract): | ||
| code = """ | ||
| import stdlib.math as math |
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 prefer just import math
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, I don't. I think that stdlib clearly establishes that it comes from the compiler. I think that it's reasonable to assume that math module could be from user-space
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.
How about vyper.math
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.
import math was added in b5e3825
|
trying to close&reopen to reflect the newest changes, due to gh bug the new commits weren't reflected |
|
|
||
|
|
||
| def _load_builtin_import(level: int, module_str: str) -> tuple[CompilerInput, vy_ast.Module]: | ||
| if not _is_builtin(module_str): # pragma: nocover |
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 don't think the pragma should be removed
| for prefix in BUILTIN_PREFIXES: | ||
| if module_str.startswith(prefix): | ||
| return prefix | ||
| return 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.
panic here, unreachable
| return None | |
| raise CompilerPanic("unreachable") # pragma: nocover |
vyper/semantics/analysis/imports.py
Outdated
|
|
||
|
|
||
| def _get_builtin_prefix(module_str: str): | ||
| for prefix in BUILTIN_PREFIXES: |
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.
nit:
| for prefix in BUILTIN_PREFIXES: | |
| for prefix in BUILTIN_PREFIXES.keys(): |
charles-cooper
left a comment
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.
couple nits, but looks good overall
|
looked at the recent commits by @charles-cooper, lgtm |
math module
What I did
implements #4515
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture