-
-
Notifications
You must be signed in to change notification settings - Fork 803
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: replace enum
with flag
keyword
#3697
Conversation
enum
with flag
keyword
@@ -23,7 +23,7 @@ | |||
) | |||
from vyper.semantics.types.shortcuts import BYTES32_T, INT256_T, UINT256_T | |||
from vyper.semantics.types.subscriptable import SArrayT | |||
from vyper.semantics.types.user import EnumT | |||
from vyper.semantics.types.user import FlagT |
Check notice
Code scanning / CodeQL
Cyclic import Note
vyper.semantics.types.user
@@ -248,13 +248,13 @@ | |||
# comparisons, e.g. `x < y` | |||
|
|||
# TODO fixme circular import | |||
from vyper.semantics.types.user import EnumT | |||
from vyper.semantics.types.user import FlagT |
Check notice
Code scanning / CodeQL
Cyclic import Note
vyper.semantics.types.user
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3697 +/- ##
==========================================
- Coverage 83.98% 83.95% -0.04%
==========================================
Files 92 92
Lines 13046 13065 +19
Branches 2928 2934 +6
==========================================
+ Hits 10957 10969 +12
- Misses 1657 1662 +5
- Partials 432 434 +2 ☔ View full report in Codecov by Sentry. |
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.
looks good, please fix that linter error and this should be good to merge!
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, thanks!
per title, replace `enum` with `flag` as it more closely models https://docs.python.org/3/library/enum.html#enum.IntFlag than regular enums. allow `enum` for now (for backwards compatibility) but convert to `flag` internally and issue a warning
What I did
Replacing the
enum
keyword withflag
to the language as per #3642. A deprecation warning is displayed when usingenum
.How I did it
New grammar was added for
flag
while keeping the old one forenum
. In the codebase all functions/classes that previously hadEnum
in their name now useFlag
.get_node
now has a condition that checks whetherenum
is being used, if it's the case it is internally replaced with flag and a warning is printed.How to verify it
Pre-existing tests for enums were adapted to test for flag
Commit message
feat: replace
enum
keyword withflag
Description for the changelog
The
enum
keyboard has been replaced byflag
.enum
will be deprecated in the future.Cute Animal Picture