From 6c9afd521e8aa8ce482384bad82fc2b0c96f2535 Mon Sep 17 00:00:00 2001 From: Real Python Bot <42617967+realpython-bot@users.noreply.github.com> Date: Tue, 27 Oct 2026 06:08:53 +0000 Subject: [PATCH] Sync fastapi-url-shortener with the maintenance update of Build a URL Shortener With FastAPI and Python Co-Authored-By: Claude Opus 5.5 --- .../source_code_final/requirements.txt | 34 ++++++++++--------- .../source_code_final/shortener_app/config.py | 5 ++- .../shortener_app/database.py | 3 +- .../shortener_app/schemas.py | 5 ++- .../source_code_step_1/requirements.txt | 34 ++++++++++--------- .../shortener_app/config.py | 5 ++- .../source_code_step_2/requirements.txt | 34 ++++++++++--------- .../shortener_app/config.py | 5 ++- .../shortener_app/database.py | 3 +- .../shortener_app/schemas.py | 5 ++- .../source_code_step_3/requirements.txt | 34 ++++++++++--------- .../shortener_app/config.py | 5 ++- .../shortener_app/database.py | 3 +- .../shortener_app/schemas.py | 5 ++- 14 files changed, 89 insertions(+), 91 deletions(-) diff --git a/fastapi-url-shortener/source_code_final/requirements.txt b/fastapi-url-shortener/source_code_final/requirements.txt index baee5cf085..6fbd62d3ed 100644 --- a/fastapi-url-shortener/source_code_final/requirements.txt +++ b/fastapi-url-shortener/source_code_final/requirements.txt @@ -1,16 +1,18 @@ -anyio==3.6.0 -asgiref==3.5.1 -click==8.1.3 -decorator==5.1.1 -fastapi==0.75.0 -h11==0.13.0 -idna==3.3 -pydantic==1.9.0 -python-dotenv==0.19.2 -six==1.16.0 -sniffio==1.2.0 -SQLAlchemy==1.4.32 -starlette==0.17.1 -typing_extensions==4.2.0 -uvicorn==0.17.6 -validators==0.18.2 +annotated-doc==0.0.5 +annotated-types==0.8.0 +anyio==4.15.1 +click==8.5.0 +fastapi==0.162.0 +h11==0.16.0 +idna==3.20 +opentelemetry-api==1.45.1 +pydantic==2.14.1 +pydantic-core==2.50.1 +pydantic-settings==2.16.1 +python-dotenv==1.2.4 +sqlalchemy==2.1.6 +starlette==1.10.0 +typing-extensions==4.16.0 +typing-inspection==0.4.4 +uvicorn==0.54.0 +validators==0.36.0 diff --git a/fastapi-url-shortener/source_code_final/shortener_app/config.py b/fastapi-url-shortener/source_code_final/shortener_app/config.py index e9cb7ddb4e..4425e3b79f 100644 --- a/fastapi-url-shortener/source_code_final/shortener_app/config.py +++ b/fastapi-url-shortener/source_code_final/shortener_app/config.py @@ -1,6 +1,6 @@ from functools import lru_cache -from pydantic import BaseSettings +from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): @@ -8,8 +8,7 @@ class Settings(BaseSettings): base_url: str = "http://localhost:8000" db_url: str = "sqlite:///./shortener.db" - class Config: - env_file = ".env" + model_config = SettingsConfigDict(env_file=".env") @lru_cache diff --git a/fastapi-url-shortener/source_code_final/shortener_app/database.py b/fastapi-url-shortener/source_code_final/shortener_app/database.py index db80427964..b6c907ef0e 100644 --- a/fastapi-url-shortener/source_code_final/shortener_app/database.py +++ b/fastapi-url-shortener/source_code_final/shortener_app/database.py @@ -1,6 +1,5 @@ from sqlalchemy import create_engine -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import declarative_base, sessionmaker from .config import get_settings diff --git a/fastapi-url-shortener/source_code_final/shortener_app/schemas.py b/fastapi-url-shortener/source_code_final/shortener_app/schemas.py index 51da8705a9..0f629a5163 100644 --- a/fastapi-url-shortener/source_code_final/shortener_app/schemas.py +++ b/fastapi-url-shortener/source_code_final/shortener_app/schemas.py @@ -1,4 +1,4 @@ -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict class URLBase(BaseModel): @@ -9,8 +9,7 @@ class URL(URLBase): is_active: bool clicks: int - class Config: - orm_mode = True + model_config = ConfigDict(from_attributes=True) class URLInfo(URL): diff --git a/fastapi-url-shortener/source_code_step_1/requirements.txt b/fastapi-url-shortener/source_code_step_1/requirements.txt index baee5cf085..6fbd62d3ed 100644 --- a/fastapi-url-shortener/source_code_step_1/requirements.txt +++ b/fastapi-url-shortener/source_code_step_1/requirements.txt @@ -1,16 +1,18 @@ -anyio==3.6.0 -asgiref==3.5.1 -click==8.1.3 -decorator==5.1.1 -fastapi==0.75.0 -h11==0.13.0 -idna==3.3 -pydantic==1.9.0 -python-dotenv==0.19.2 -six==1.16.0 -sniffio==1.2.0 -SQLAlchemy==1.4.32 -starlette==0.17.1 -typing_extensions==4.2.0 -uvicorn==0.17.6 -validators==0.18.2 +annotated-doc==0.0.5 +annotated-types==0.8.0 +anyio==4.15.1 +click==8.5.0 +fastapi==0.162.0 +h11==0.16.0 +idna==3.20 +opentelemetry-api==1.45.1 +pydantic==2.14.1 +pydantic-core==2.50.1 +pydantic-settings==2.16.1 +python-dotenv==1.2.4 +sqlalchemy==2.1.6 +starlette==1.10.0 +typing-extensions==4.16.0 +typing-inspection==0.4.4 +uvicorn==0.54.0 +validators==0.36.0 diff --git a/fastapi-url-shortener/source_code_step_1/shortener_app/config.py b/fastapi-url-shortener/source_code_step_1/shortener_app/config.py index e9cb7ddb4e..4425e3b79f 100644 --- a/fastapi-url-shortener/source_code_step_1/shortener_app/config.py +++ b/fastapi-url-shortener/source_code_step_1/shortener_app/config.py @@ -1,6 +1,6 @@ from functools import lru_cache -from pydantic import BaseSettings +from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): @@ -8,8 +8,7 @@ class Settings(BaseSettings): base_url: str = "http://localhost:8000" db_url: str = "sqlite:///./shortener.db" - class Config: - env_file = ".env" + model_config = SettingsConfigDict(env_file=".env") @lru_cache diff --git a/fastapi-url-shortener/source_code_step_2/requirements.txt b/fastapi-url-shortener/source_code_step_2/requirements.txt index baee5cf085..6fbd62d3ed 100644 --- a/fastapi-url-shortener/source_code_step_2/requirements.txt +++ b/fastapi-url-shortener/source_code_step_2/requirements.txt @@ -1,16 +1,18 @@ -anyio==3.6.0 -asgiref==3.5.1 -click==8.1.3 -decorator==5.1.1 -fastapi==0.75.0 -h11==0.13.0 -idna==3.3 -pydantic==1.9.0 -python-dotenv==0.19.2 -six==1.16.0 -sniffio==1.2.0 -SQLAlchemy==1.4.32 -starlette==0.17.1 -typing_extensions==4.2.0 -uvicorn==0.17.6 -validators==0.18.2 +annotated-doc==0.0.5 +annotated-types==0.8.0 +anyio==4.15.1 +click==8.5.0 +fastapi==0.162.0 +h11==0.16.0 +idna==3.20 +opentelemetry-api==1.45.1 +pydantic==2.14.1 +pydantic-core==2.50.1 +pydantic-settings==2.16.1 +python-dotenv==1.2.4 +sqlalchemy==2.1.6 +starlette==1.10.0 +typing-extensions==4.16.0 +typing-inspection==0.4.4 +uvicorn==0.54.0 +validators==0.36.0 diff --git a/fastapi-url-shortener/source_code_step_2/shortener_app/config.py b/fastapi-url-shortener/source_code_step_2/shortener_app/config.py index e9cb7ddb4e..4425e3b79f 100644 --- a/fastapi-url-shortener/source_code_step_2/shortener_app/config.py +++ b/fastapi-url-shortener/source_code_step_2/shortener_app/config.py @@ -1,6 +1,6 @@ from functools import lru_cache -from pydantic import BaseSettings +from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): @@ -8,8 +8,7 @@ class Settings(BaseSettings): base_url: str = "http://localhost:8000" db_url: str = "sqlite:///./shortener.db" - class Config: - env_file = ".env" + model_config = SettingsConfigDict(env_file=".env") @lru_cache diff --git a/fastapi-url-shortener/source_code_step_2/shortener_app/database.py b/fastapi-url-shortener/source_code_step_2/shortener_app/database.py index db80427964..b6c907ef0e 100644 --- a/fastapi-url-shortener/source_code_step_2/shortener_app/database.py +++ b/fastapi-url-shortener/source_code_step_2/shortener_app/database.py @@ -1,6 +1,5 @@ from sqlalchemy import create_engine -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import declarative_base, sessionmaker from .config import get_settings diff --git a/fastapi-url-shortener/source_code_step_2/shortener_app/schemas.py b/fastapi-url-shortener/source_code_step_2/shortener_app/schemas.py index 51da8705a9..0f629a5163 100644 --- a/fastapi-url-shortener/source_code_step_2/shortener_app/schemas.py +++ b/fastapi-url-shortener/source_code_step_2/shortener_app/schemas.py @@ -1,4 +1,4 @@ -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict class URLBase(BaseModel): @@ -9,8 +9,7 @@ class URL(URLBase): is_active: bool clicks: int - class Config: - orm_mode = True + model_config = ConfigDict(from_attributes=True) class URLInfo(URL): diff --git a/fastapi-url-shortener/source_code_step_3/requirements.txt b/fastapi-url-shortener/source_code_step_3/requirements.txt index baee5cf085..6fbd62d3ed 100644 --- a/fastapi-url-shortener/source_code_step_3/requirements.txt +++ b/fastapi-url-shortener/source_code_step_3/requirements.txt @@ -1,16 +1,18 @@ -anyio==3.6.0 -asgiref==3.5.1 -click==8.1.3 -decorator==5.1.1 -fastapi==0.75.0 -h11==0.13.0 -idna==3.3 -pydantic==1.9.0 -python-dotenv==0.19.2 -six==1.16.0 -sniffio==1.2.0 -SQLAlchemy==1.4.32 -starlette==0.17.1 -typing_extensions==4.2.0 -uvicorn==0.17.6 -validators==0.18.2 +annotated-doc==0.0.5 +annotated-types==0.8.0 +anyio==4.15.1 +click==8.5.0 +fastapi==0.162.0 +h11==0.16.0 +idna==3.20 +opentelemetry-api==1.45.1 +pydantic==2.14.1 +pydantic-core==2.50.1 +pydantic-settings==2.16.1 +python-dotenv==1.2.4 +sqlalchemy==2.1.6 +starlette==1.10.0 +typing-extensions==4.16.0 +typing-inspection==0.4.4 +uvicorn==0.54.0 +validators==0.36.0 diff --git a/fastapi-url-shortener/source_code_step_3/shortener_app/config.py b/fastapi-url-shortener/source_code_step_3/shortener_app/config.py index e9cb7ddb4e..4425e3b79f 100644 --- a/fastapi-url-shortener/source_code_step_3/shortener_app/config.py +++ b/fastapi-url-shortener/source_code_step_3/shortener_app/config.py @@ -1,6 +1,6 @@ from functools import lru_cache -from pydantic import BaseSettings +from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): @@ -8,8 +8,7 @@ class Settings(BaseSettings): base_url: str = "http://localhost:8000" db_url: str = "sqlite:///./shortener.db" - class Config: - env_file = ".env" + model_config = SettingsConfigDict(env_file=".env") @lru_cache diff --git a/fastapi-url-shortener/source_code_step_3/shortener_app/database.py b/fastapi-url-shortener/source_code_step_3/shortener_app/database.py index db80427964..b6c907ef0e 100644 --- a/fastapi-url-shortener/source_code_step_3/shortener_app/database.py +++ b/fastapi-url-shortener/source_code_step_3/shortener_app/database.py @@ -1,6 +1,5 @@ from sqlalchemy import create_engine -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import declarative_base, sessionmaker from .config import get_settings diff --git a/fastapi-url-shortener/source_code_step_3/shortener_app/schemas.py b/fastapi-url-shortener/source_code_step_3/shortener_app/schemas.py index 51da8705a9..0f629a5163 100644 --- a/fastapi-url-shortener/source_code_step_3/shortener_app/schemas.py +++ b/fastapi-url-shortener/source_code_step_3/shortener_app/schemas.py @@ -1,4 +1,4 @@ -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict class URLBase(BaseModel): @@ -9,8 +9,7 @@ class URL(URLBase): is_active: bool clicks: int - class Config: - orm_mode = True + model_config = ConfigDict(from_attributes=True) class URLInfo(URL):