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

Imported Enums are Not Equal #16

Closed
georgetayqy opened this issue Jun 4, 2024 · 1 comment
Closed

Imported Enums are Not Equal #16

georgetayqy opened this issue Jun 4, 2024 · 1 comment

Comments

@georgetayqy
Copy link
Contributor

georgetayqy commented Jun 4, 2024

Bug Report

What happened

The current code base uses enums imported from another module in the same project directory.

However, as detailed in this GitHub issue, Python enums are not equal if they enums are compared across modules, unlike other programming languages such as Java.

This causes some functions to break, especially those that rely on the equality of the enums to perform an action.

Let's move to fix this bug to restore the application to a working state.

Platform and OS

  • Python 3.12.3
  • MacOS Sonoma 14.4.1, running on a M1 Pro

Logs (if applicable)

N/A

@georgetayqy
Copy link
Contributor Author

georgetayqy commented Jun 11, 2024

This issue can be resolved by doing an isinstance check on the imported enum, then using the enum's constructor on the imported enum value to convert to the correct enum type.

While it may be a roundabout way of resolving this issue, the added benefit that the enums bring (clearer type annotations, restriction of permitted values, modularity and extensivity) outweighs any boilerplate code that needs to be written.

See PR #17 for more info.

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

No branches or pull requests

1 participant