ssg-wsg / Sample-Codes

This repository contains sample codes (Encryption Decryption, Java, Node.js and Python) to guide and support your application development on SSG-WSG Developer Portal.
3 stars 8 forks source link

Imported Enums are Not Equal #16

Closed asdfghjkxd closed 2 months ago

asdfghjkxd commented 3 months ago

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

Logs (if applicable)

N/A

asdfghjkxd commented 2 months ago

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.