-
Notifications
You must be signed in to change notification settings - Fork 6
[#38] code migration to use pydantic v2 #51
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
base: develop
Are you sure you want to change the base?
Changes from 24 commits
08e8c93
dca1631
00be384
d997914
d205fdd
a0938f0
e76482a
cba00f9
ccb107e
c68dd11
f993e4b
a5ca4d4
eaacbde
3d9deff
d455438
4bad6ef
bd69aac
d761cae
0f61ba7
67298c5
c4c22db
486dba1
71f7550
43d2d0a
513c88e
bf0b427
807eff1
a5f0dae
f5cd531
a552324
337eae2
adc37da
e2120ba
43896a6
798a1b9
18d3608
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| from functools import lru_cache | ||
| from typing import Any | ||
|
|
||
| from pydantic import BaseSettings, HttpUrl | ||
| from pydantic import HttpUrl | ||
| from pydantic_settings import BaseSettings, SettingsConfigDict | ||
| from dotenv import load_dotenv | ||
|
|
||
| # had to use load_dotenv() to get the env variables to work during testing | ||
|
|
@@ -24,13 +25,14 @@ def __init__(self, **data: Any) -> None: | |
| super().__init__(**data) | ||
| if self.testing: | ||
| self.database_name = f"{self.database_name}" | ||
| self.hydroshare_meta_read_url = str(self.hydroshare_meta_read_url) | ||
| self.hydroshare_file_read_url = str(self.hydroshare_file_read_url) | ||
|
||
|
|
||
| @property | ||
| def db_connection_string(self): | ||
| return f"{self.db_protocol}://{self.db_username}:{self.db_password}@{self.db_host}/?retryWrites=true&w=majority" | ||
|
|
||
| class Config: | ||
| env_file = ".env" | ||
| model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noting that I have since learned that if we leave the env_file Config out then it just reads environment variables which eases deployments. This comment is not relevant to these changes, just making a note here. |
||
|
|
||
|
|
||
| @lru_cache() | ||
|
|
||
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.
Should the Organization.funder.url attribute be updated to an HttpUrl instead of casting to a string here?
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.
The funder url has been updated to type HttpUrl:
https://github.com/I-GUIDE/catalogapi/blob/38-update-to-pydantic-v2/api/adapters/hydroshare.py#L53