From 3ef87e011315d7118e016952dc9dce48c44cafab Mon Sep 17 00:00:00 2001 From: David Brochart Date: Wed, 12 Jul 2023 18:20:55 +0200 Subject: [PATCH] Use pydantic v2 --- jupyverse_api/jupyverse_api/__init__.py | 5 ++--- jupyverse_api/pyproject.toml | 2 +- plugins/contents/fps_contents/routes.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/jupyverse_api/jupyverse_api/__init__.py b/jupyverse_api/jupyverse_api/__init__.py index 1994d6e4..ccd3d325 100644 --- a/jupyverse_api/jupyverse_api/__init__.py +++ b/jupyverse_api/jupyverse_api/__init__.py @@ -1,6 +1,6 @@ from typing import Dict -from pydantic import BaseModel, Extra +from pydantic import BaseModel from .app import App @@ -18,8 +18,7 @@ def __call__(cls, *args, **kwargs): class Config(BaseModel): - class Config: - extra = Extra.forbid + model_config = {"extra": "forbid"} class Router: diff --git a/jupyverse_api/pyproject.toml b/jupyverse_api/pyproject.toml index 19889dd9..bb4d0e43 100644 --- a/jupyverse_api/pyproject.toml +++ b/jupyverse_api/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ - "pydantic >=1.10.6,<2", + "pydantic >=2,<3", "fastapi >=0.95.0,<1", "rich-click >=1.6.1,<2", "asphalt >=4.11.0,<5", diff --git a/plugins/contents/fps_contents/routes.py b/plugins/contents/fps_contents/routes.py index 528926ce..4663885a 100644 --- a/plugins/contents/fps_contents/routes.py +++ b/plugins/contents/fps_contents/routes.py @@ -146,7 +146,7 @@ async def read_content( if get_content: if path.is_dir(): content = [ - (await self.read_content(subpath, get_content=False)).dict() + (await self.read_content(subpath, get_content=False)).model_dump() for subpath in path.iterdir() if not subpath.name.startswith(".") ]