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

Refactor(users): use enum.Enum for GRADE_NUMBERS #1625

Closed
wants to merge 4 commits into from

Conversation

JasonGrace2282
Copy link
Member

Proposed changes

  • Use an enum for GRADE_NUMBERS instead of a 2D array

Brief description of rationale

Python enums are much more flexible and readable then a 2D array. You can read a nice answer about their benefits here

Comments

It is recommended that attributes of enums should be in all caps but in order to make the PR easier to review (smaller diff) I chose to make the attributes of the enum lowercase.

@JasonGrace2282 JasonGrace2282 requested a review from a team as a code owner March 16, 2024 17:52
@JasonGrace2282 JasonGrace2282 marked this pull request as draft March 16, 2024 18:48
Implemented a __contains__ to check if item is in enum

test(preferences): remove unused import

test: run scripts

test(codacy): use f-string
@NotFish232
Copy link
Member

Hi Aarush. Thanks for the PR! I understand (and agree) with you on the benefits of enums, but in this case, I think the current implementation is better. 2D arrays mesh much better with how django normally wants field choices organized (like in the grade_number field on photos, where you convert the enum to a 2D array anyways). Since User is such a core model in ion, this change would be hard to test, and may lead to unexpected behavior in other apps, for not much actual benefit in code quality. Because of that, we can't accept this change and encourage you to work on other issues you find instead — issues tagged with “good first issue” are a great place to start.

@JasonGrace2282
Copy link
Member Author

Makes sense, I'll close this PR then!

@JasonGrace2282 JasonGrace2282 deleted the enums branch March 18, 2024 23:45
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.

2 participants