Skip to content

Commit

Permalink
refactor: use pydantic v2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Nov 24, 2024
1 parent e949e04 commit 35167ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion silverback/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def __init__(self, settings: Settings | None = None):
):
settings.NEW_BLOCK_TIMEOUT = int(timedelta(days=1).total_seconds())

settings_str = "\n ".join(f'{key}="{val}"' for key, val in settings.dict().items() if val)
settings_str = "\n ".join(
f'{key}="{val}"' for key, val in settings.model_dump().items() if val
)
logger.info(f"Loading Silverback Bot with settings:\n {settings_str}")

self.broker = settings.get_broker()
Expand Down
2 changes: 1 addition & 1 deletion silverback/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def init(self, bot_id: SilverbackID) -> StateSnapshot | None:
self.state_backup_file = data_folder / "state.json"

return (
StateSnapshot.parse_file(self.state_backup_file)
StateSnapshot.model_validate_json(self.state_backup_file.read_text())
if self.state_backup_file.exists()
else None
)
Expand Down

0 comments on commit 35167ae

Please sign in to comment.