-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: Convert config template to pydantic model #1364
Conversation
ab33df1
to
94f6d19
Compare
94f6d19
to
93eade4
Compare
I'm definitely doing something wrong here but I'm not familiar with yaml.
|
Use |
Perfect, thanks @MoritzWeber0, I switched to BaseModels so I could use model_dump() and now it's almost correct, just need to tweak a few fields I entered incorrectly. Last question would be: how do we present or implement this for the user?
Option A would obviously only take me a few minutes, I'd need a little starting direction for Option B so I knew where to look. |
Go for option A:
|
93eade4
to
b4305b9
Compare
411e162
to
8f34a29
Compare
19c20ac
to
ae531cc
Compare
c3168bd
to
dccc22e
Compare
3ac7c9d
to
f51aa91
Compare
e3aeb12
to
3530e49
Compare
url: str = pydantic.Field( | ||
default="postgresql://dev:dev@localhost:5432/dev", | ||
description="The URL of the database (format: postgresql://[userspec@][hostspec][/dbname][?paramspec]).", | ||
examples=["postgresql://dev:dev@localhost:5432/dev"], |
Check failure
Code scanning / SonarCloud
PostgreSQL database passwords should not be disclosed
|
||
class DatabaseConfig(BaseConfig): | ||
url: str = pydantic.Field( | ||
default="postgresql://dev:dev@localhost:5432/dev", |
Check failure
Code scanning / SonarCloud
PostgreSQL database passwords should not be disclosed
82c125a
to
0f08c64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @romeonicholas. This is one of the best PRs of this year and will significantly improve my life. Finally, we have typing of the configuration.
I love the precision of changes and the accurate descriptions and examples. I did some changes and added conversations for it, but everything is already resolved. It's just for transparency what I've changed.
Tested on staging and works like a dream.
I'd just refactor the tests slightly: Instead of using unittest mock, I'd switch to Python classes which have typing and autocomplete.
b62e344
to
ca054ac
Compare
Co-authored-by: MoritzWeber0 <[email protected]>
ca054ac
to
66728d2
Compare
Quality Gate passedIssues Measures |
Resolves #1165 by replacing the configuration template with a pydantic object from which default configurations can be written.