Skip to content
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

Merged
merged 14 commits into from
Dec 23, 2023

Conversation

AlbertoCentonze
Copy link
Contributor

@AlbertoCentonze AlbertoCentonze commented Dec 17, 2023

What I did

Replacing the enum keyword with flag to the language as per #3642. A deprecation warning is displayed when using enum.

How I did it

New grammar was added for flag while keeping the old one for enum. In the codebase all functions/classes that previously had Enum in their name now use Flag. get_node now has a condition that checks whether enum 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 with flag

Description for the changelog

The enum keyboard has been replaced by flag. enum will be deprecated in the future.

Cute Animal Picture

image

@AlbertoCentonze AlbertoCentonze changed the title feat: adding flag keyword feat: replace enum with flag keyword Dec 17, 2023
@AlbertoCentonze AlbertoCentonze marked this pull request as ready for review December 17, 2023 18:26
vyper/ast/nodes.py Outdated Show resolved Hide resolved
@@ -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

Import of module
vyper.semantics.types.user
begins an import cycle.
@@ -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

Import of module
vyper.semantics.types.user
begins an import cycle.
@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (b0ea5b6) 83.98% compared to head (fad53f8) 83.95%.
Report is 4 commits behind head on master.

Files Patch % Lines
vyper/ast/nodes.py 45.45% 4 Missing and 2 partials ⚠️
vyper/codegen/expr.py 66.66% 0 Missing and 1 partial ⚠️

❗ 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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@charles-cooper charles-cooper left a 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!

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@charles-cooper charles-cooper enabled auto-merge (squash) December 23, 2023 15:41
@charles-cooper charles-cooper merged commit 88c09a2 into vyperlang:master Dec 23, 2023
84 checks passed
charles-cooper pushed a commit to charles-cooper/vyper that referenced this pull request Dec 27, 2023
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
DanielSchiavini added a commit to DanielSchiavini/vyper-plugin that referenced this pull request Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants