feat[lang]!: move sqrt to new stdlib math module#4520
feat[lang]!: move sqrt to new stdlib math module#4520charles-cooper merged 14 commits intovyperlang:masterfrom
math module#4520Conversation
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 |
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.
maybe we should physically move these to the stdlib/ directory
There was a problem hiding this comment.
(to fuse the two branches)
There was a problem hiding this comment.
won't it still require a condition?
There was a problem hiding this comment.
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.
i prefer just import math
There was a problem hiding this comment.
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
|
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.
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.
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.
nit:
| for prefix in BUILTIN_PREFIXES: | |
| for prefix in BUILTIN_PREFIXES.keys(): |
charles-cooper
left a comment
There was a problem hiding this comment.
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