Skip to content

Part 8: Support New Python ver <3.12 and Update FastAPI #62

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions part-08-structure-and-versioning/app/backend_pre_start.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from tenacity import after_log, before_log, retry, stop_after_attempt, wait_fixed

from sqlalchemy.sql import text
from app.db.session import SessionLocal

logging.basicConfig(level=logging.INFO)
Expand All @@ -21,7 +21,7 @@ def init() -> None:
try:
db = SessionLocal()
# Try to create session to check if DB is awake
db.execute("SELECT 1")
db.execute(text("SELECT 1"))
except Exception as e:
logger.error(e)
raise e
Expand Down
3 changes: 2 additions & 1 deletion part-08-structure-and-versioning/app/core/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pathlib

from pydantic import AnyHttpUrl, BaseSettings, EmailStr, validator
from pydantic import AnyHttpUrl, EmailStr, validator
from pydantic_settings import BaseSettings
from typing import List, Optional, Union


Expand Down
3 changes: 2 additions & 1 deletion part-08-structure-and-versioning/app/db/init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def init_db(db: Session) -> None:
user = crud.user.get_by_email(db, email=settings.FIRST_SUPERUSER)
if not user:
user_in = schemas.UserCreate(
full_name="Initial Super User",
first_name="First_name",
surname="Surname",
email=settings.FIRST_SUPERUSER,
is_superuser=True,
)
Expand Down
2 changes: 1 addition & 1 deletion part-08-structure-and-versioning/app/schemas/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RecipeInDBBase(RecipeBase):
submitter_id: int

class Config:
orm_mode = True
from_attributes = True


# Properties to return to client
Expand Down
2 changes: 1 addition & 1 deletion part-08-structure-and-versioning/app/schemas/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UserInDBBase(UserBase):
id: Optional[int] = None

class Config:
orm_mode = True
from_attributes = True


# Additional properties to return via API
Expand Down
1,354 changes: 911 additions & 443 deletions part-08-structure-and-versioning/poetry.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions part-08-structure-and-versioning/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ description = "Ultimate FastAPI Tutorial"
authors = ["ChristopherGS"]

[tool.poetry.dependencies]
python = "^3.8"
uvicorn = "~0.11.3"
fastapi = "~0.68.0"
python = ">=3.8,<3.12"
uvicorn = {extras=["standard"], version="~0.23.0"}
fastapi = "^0.104.0"
python-multipart = "~0.0.5"
pydantic = {extras = ["email"], version = "~1.8.1"}
pydantic = {extras = ["email"], version = ">=2.0"}
pydantic-settings = ">=2.0"
Jinja2 = "^3.0.1"
SQLAlchemy = "^1.4.22"
SQLAlchemy = ">=2.0"
alembic = "^1.6.5"
tenacity = "^8.0.1"
greenlet = "^1.1.2"