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

Remove enum prefixes #187

Merged
merged 47 commits into from
Oct 25, 2023
Merged

Conversation

Gobot1234
Copy link
Collaborator

@Gobot1234 Gobot1234 commented Dec 18, 2020

Summary

Removes any enum class name prefixes from enum members.

NONE -> NONE
ARITHMETIC_OPERATOR_NONE -> NONE

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
    • This change has an associated test
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

Closes #174
Closes #302

@Gobot1234 Gobot1234 changed the title Implement Message.__bool__ for #130 Remove enum prefixes Dec 18, 2020
@Gobot1234
Copy link
Collaborator Author

I might actually just update this to remove any prefix on an enum that is the same for all the members.

src/betterproto/compile/naming.py Outdated Show resolved Hide resolved
cetanu
cetanu previously approved these changes Dec 24, 2021
@Gobot1234 Gobot1234 mentioned this pull request Dec 29, 2021
3 tasks
@Gobot1234 Gobot1234 mentioned this pull request Mar 4, 2022
3 tasks
# Conflicts:
#	src/betterproto/plugin/models.py
#	tests/inputs/enum/test_enum.py
@Gobot1234
Copy link
Collaborator Author

Failure looks unrelated

Copy link
Collaborator

@cetanu cetanu left a 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 😅

@ryanwradtke
Copy link

Has this really been blocked for 2 years?

nat-n
nat-n previously requested changes Jul 16, 2022
Copy link
Collaborator

@nat-n nat-n left a 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.

src/betterproto/casing.py Show resolved Hide resolved

def pythonize_enum_member_name(name: str, enum_name: str) -> str:
enum_name = casing.snake_case(enum_name).upper()
find = name.find(enum_name)
Copy link
Collaborator

@nat-n nat-n Jul 16, 2022

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.

@Gobot1234 Gobot1234 requested a review from cetanu December 2, 2022 22:43
cetanu
cetanu previously approved these changes Oct 15, 2023
Copy link
Collaborator

@cetanu cetanu left a 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.

@Gobot1234 Gobot1234 requested a review from cetanu October 16, 2023 11:55
@cetanu cetanu dismissed nat-n’s stale review October 16, 2023 22:17

Resolved comments due to lack of disagreement

@Gobot1234 Gobot1234 merged commit bd7de20 into danielgtaylor:master Oct 25, 2023
17 checks passed
@Gobot1234 Gobot1234 deleted the remove-enum-prefix branch October 25, 2023 21:35
@snikch
Copy link

snikch commented Aug 4, 2024

FYI this has broken the ability to use enums in JSON payloads cross platform as the JSON value has been stripped of the prefix too.

From the linked C# docs in #174:

This name transformation does not affect the text used within the JSON representation of messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enum with reserved word (None) clashes with python Enum Prefix is not stripped
7 participants