mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 12:29:42 +00:00
👷 Add ty to precommit (#2227)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8bf0025039
commit
2fdd62ce0c
@@ -63,6 +63,7 @@ def run_migrations_online():
|
||||
|
||||
"""
|
||||
configuration = config.get_section(config.config_ini_section)
|
||||
assert configuration is not None
|
||||
configuration["sqlalchemy.url"] = get_url()
|
||||
connectable = engine_from_config(
|
||||
configuration,
|
||||
|
||||
@@ -29,7 +29,7 @@ def upgrade():
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'item', type_='foreignkey')
|
||||
op.drop_constraint('item_owner_id_fkey', 'item', type_='foreignkey')
|
||||
op.create_foreign_key('item_owner_id_fkey', 'item', 'user', ['owner_id'], ['id'])
|
||||
op.alter_column('item', 'owner_id',
|
||||
existing_type=sa.UUID(),
|
||||
|
||||
@@ -41,7 +41,8 @@ def read_items(
|
||||
)
|
||||
items = session.exec(statement).all()
|
||||
|
||||
return ItemsPublic(data=items, count=count)
|
||||
items_public = [ItemPublic.model_validate(item) for item in items]
|
||||
return ItemsPublic(data=items_public, count=count)
|
||||
|
||||
|
||||
@router.get("/{id}", response_model=ItemPublic)
|
||||
|
||||
@@ -47,7 +47,8 @@ def read_users(session: SessionDep, skip: int = 0, limit: int = 100) -> Any:
|
||||
)
|
||||
users = session.exec(statement).all()
|
||||
|
||||
return UsersPublic(data=users, count=count)
|
||||
users_public = [UserPublic.model_validate(user) for user in users]
|
||||
return UsersPublic(data=users_public, count=count)
|
||||
|
||||
|
||||
@router.post(
|
||||
|
||||
@@ -31,7 +31,7 @@ class UserRegister(SQLModel):
|
||||
|
||||
# Properties to receive via API on update, all are optional
|
||||
class UserUpdate(UserBase):
|
||||
email: EmailStr | None = Field(default=None, max_length=255) # type: ignore
|
||||
email: EmailStr | None = Field(default=None, max_length=255) # type: ignore[assignment]
|
||||
password: str | None = Field(default=None, min_length=8, max_length=128)
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class ItemCreate(ItemBase):
|
||||
|
||||
# Properties to receive on item update
|
||||
class ItemUpdate(ItemBase):
|
||||
title: str | None = Field(default=None, min_length=1, max_length=255) # type: ignore
|
||||
title: str | None = Field(default=None, min_length=1, max_length=255) # type: ignore[assignment]
|
||||
|
||||
|
||||
# Database model, database table inferred from class name
|
||||
|
||||
@@ -4,7 +4,7 @@ from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import emails # type: ignore
|
||||
import emails # type: ignore[import-untyped]
|
||||
import jwt
|
||||
from jinja2 import Template
|
||||
from jwt.exceptions import InvalidTokenError
|
||||
|
||||
@@ -25,6 +25,7 @@ dependencies = [
|
||||
dev = [
|
||||
"pytest<8.0.0,>=7.4.3",
|
||||
"mypy<2.0.0,>=1.8.0",
|
||||
"ty>=0.0.25",
|
||||
"ruff<1.0.0,>=0.2.2",
|
||||
"prek>=0.2.24,<1.0.0",
|
||||
"coverage<8.0.0,>=7.4.3",
|
||||
@@ -75,3 +76,6 @@ sort = "-Cover"
|
||||
|
||||
[tool.coverage.html]
|
||||
show_contexts = true
|
||||
|
||||
[tool.ty.terminal]
|
||||
error-on-warning = true
|
||||
|
||||
@@ -4,5 +4,6 @@ set -e
|
||||
set -x
|
||||
|
||||
mypy app
|
||||
ty check app
|
||||
ruff check app
|
||||
ruff format app --check
|
||||
|
||||
Reference in New Issue
Block a user