-
Notifications
You must be signed in to change notification settings - Fork 219
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
Remove enum prefixes #187
Remove enum prefixes #187
Conversation
Fix issue in logic for evaluating field types affecting python 3.9
* Update locked dependencies to fix grpcio compile issue with python 3.9 * ci: add python 3.9
I might actually just update this to remove any prefix on an enum that is the same for all the members. |
# Conflicts: # src/betterproto/plugin/models.py # tests/inputs/enum/test_enum.py
Failure looks unrelated |
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 assume you will squash the commits for this 😅
Has this really been blocked for 2 years? |
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.
Hi, just dropping by again. You can get someone else to approve and merge this, but if you want my opinion it needs a little more thought.
|
||
def pythonize_enum_member_name(name: str, enum_name: str) -> str: | ||
enum_name = casing.snake_case(enum_name).upper() | ||
find = name.find(enum_name) |
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 still think this implementation is unclear and error prone. For example imagine the chaos given an enum type with a single letter name! If the intention is to remove a "prefix", then just remove the prefix.
If you feel it's necessary to make it more clever than that (which I'm skeptical of) then a docstring explanation and test coverage are essential.
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've looked over the files again, I am okay with this change. If some complication arises we can deal with it later.
Resolved comments due to lack of disagreement
Summary
Removes any enum class name prefixes from enum members.
NONE -> NONE
ARITHMETIC_OPERATOR_NONE -> NONE
Checklist
Closes #174
Closes #302