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

sodym pydantic class with default model_config #59

Open
JakobBD opened this issue Nov 25, 2024 · 0 comments
Open

sodym pydantic class with default model_config #59

JakobBD opened this issue Nov 25, 2024 · 0 comments

Comments

@JakobBD
Copy link
Collaborator

JakobBD commented Nov 25, 2024

Instead of classes inheriting from pydantic BaseClass, we could make a SodymPydanticModel class, with a default config such as

    model_config = ConfigDict(arbitrary_types_allowed=True, protected_namespaces=(), extra='forbid')
  • The first argument would mean we don't have to add it manually everywhere we use non-standard types
  • The second argument solves sphinx errors, as suggested in this very helpful comment ;-)
  • The third may be the most debatable. I find extras=ignore a bit dangerous, since typos are not caught if the fields have default values. This is especially dangerous if we load class arguments from a dict, such as from the yml config file. In some classes, we add attributes later on, so we are setting extras=allow there, which would create a conflict. Happy to discuss this.
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