diff --git a/models.py b/models.py index ff24dba..1897f10 100644 --- a/models.py +++ b/models.py @@ -1,20 +1,30 @@ from datetime import datetime from enum import Enum -from typing import Any, List +from typing import Annotated, Any, List import strawberry from bson import ObjectId from pydantic import ( - AnyHttpUrl, BaseModel, + BeforeValidator, ConfigDict, EmailStr, Field, + HttpUrl, + TypeAdapter, field_validator, ) from pydantic_core import core_schema from pytz import timezone +http_url_adapter = TypeAdapter(HttpUrl) +HttpUrlString = Annotated[ + str, + BeforeValidator( + lambda value: str(http_url_adapter.validate_python(value)) + ), +] + def create_utc_time(): return datetime.now(timezone("UTC")) @@ -75,15 +85,15 @@ class EnumCategories(str, Enum): class Social(BaseModel): - website: AnyHttpUrl | None = None - instagram: AnyHttpUrl | None = None - facebook: AnyHttpUrl | None = None - youtube: AnyHttpUrl | None = None - twitter: AnyHttpUrl | None = None - linkedin: AnyHttpUrl | None = None - discord: AnyHttpUrl | None = None - whatsapp: AnyHttpUrl | None = None - other_links: List[AnyHttpUrl] = Field([]) # Type and URL + website: HttpUrlString | None = None + instagram: HttpUrlString | None = None + facebook: HttpUrlString | None = None + youtube: HttpUrlString | None = None + twitter: HttpUrlString | None = None + linkedin: HttpUrlString | None = None + discord: HttpUrlString | None = None + whatsapp: HttpUrlString | None = None + other_links: List[HttpUrlString] = Field([]) # Type and URL @field_validator("other_links") @classmethod diff --git a/requirements.txt b/requirements.txt index c01e944..2da3a8b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,18 @@ -anyio==4.6.2 +anyio==4.6.2.post1 click==8.1.7 dnspython==2.7.0 email_validator >=2.2.0 -fastapi==0.115.4 +fastapi==0.115.5 graphql-core==3.2.5 greenlet==3.1.1 h11==0.14.0 idna==3.10 -libcst==1.5.0 +libcst==1.5.1 msgpack==1.1.0 mypy-extensions==1.0.0 pathspec==0.12.1 platformdirs==4.3.6 -pydantic>=2.9.2,<3.0.0 +pydantic>=2.10.1,<3.0.0 Pygments==2.18.0 pymongo==4.10.1 python-dateutil>=2.9.0.post0 @@ -22,9 +22,9 @@ requests>=2.32.3 rich==13.9.4 six==1.16.0 sniffio==1.3.1 -starlette>=0.41.2,<0.42.0 -strawberry-graphql[fastapi]==0.247.1 -tomli==2.0.2 -typer==0.12.5 +starlette>=0.41.3,<0.42.0 +strawberry-graphql[fastapi]==0.252.0 +tomli==2.1.0 +typer==0.13.1 typing-extensions>=4.12.2 -uvicorn==0.32.0 +uvicorn==0.32.1