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

Enforce type of _typ to a single value instead of Enum type + default value #833

Open
lord-haffi opened this issue Jun 14, 2024 · 0 comments
Labels
ENUMs technisch aka technical

Comments

@lord-haffi
Copy link
Collaborator

Currently, it is theoretically possible (and therefore defined in the JSON-schemas) that a BO like Vertrag can hold a different value in _typ than "VERTRAG". This should be avoided. Instead, we should define the type like typ: Annotated[Literal["VERTRAG", None], Field(alias="_typ")] = "VERTRAG". We already set the default-value in every class, i.e. imo we don't profit from the enum pattern here.

This would also make the enum Typ obsolete. Optionally, we could create the enum dynamically by querying all Literal types in bo and com, but I don't think that we would need that.

Please note that it is currently impossible in Python to define Literals with enum members. It has to be a constant string.

What are your thoughts on this?
@hf-kklein, @hf-krechan, @hf-fvesely, @hf-aschloegl, @snsttr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENUMs technisch aka technical
Projects
None yet
Development

No branches or pull requests

1 participant