diff --git a/{{cookiecutter.project_slug}}/backend/app/alembic/env.py b/{{cookiecutter.project_slug}}/backend/app/alembic/env.py index df37198286..3ba3420643 100755 --- a/{{cookiecutter.project_slug}}/backend/app/alembic/env.py +++ b/{{cookiecutter.project_slug}}/backend/app/alembic/env.py @@ -67,11 +67,9 @@ def run_migrations_online(): """ configuration = config.get_section(config.config_ini_section) - configuration['sqlalchemy.url'] = get_url() + configuration["sqlalchemy.url"] = get_url() connectable = engine_from_config( - configuration, - prefix="sqlalchemy.", - poolclass=pool.NullPool, + configuration, prefix="sqlalchemy.", poolclass=pool.NullPool, ) with connectable.connect() as connection: diff --git a/{{cookiecutter.project_slug}}/backend/app/alembic/versions/d4867f3a4c0a_first_revision.py b/{{cookiecutter.project_slug}}/backend/app/alembic/versions/d4867f3a4c0a_first_revision.py index 68b3ee4f1c..a43bf9d2fd 100644 --- a/{{cookiecutter.project_slug}}/backend/app/alembic/versions/d4867f3a4c0a_first_revision.py +++ b/{{cookiecutter.project_slug}}/backend/app/alembic/versions/d4867f3a4c0a_first_revision.py @@ -1,7 +1,7 @@ """First revision Revision ID: d4867f3a4c0a -Revises: +Revises: Create Date: 2019-04-17 13:53:32.978401 """ @@ -10,7 +10,7 @@ # revision identifiers, used by Alembic. -revision = 'd4867f3a4c0a' +revision = "d4867f3a4c0a" down_revision = None branch_labels = None depends_on = None @@ -18,40 +18,42 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.create_table('user', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('full_name', sa.String(), nullable=True), - sa.Column('email', sa.String(), nullable=True), - sa.Column('hashed_password', sa.String(), nullable=True), - sa.Column('is_active', sa.Boolean(), nullable=True), - sa.Column('is_superuser', sa.Boolean(), nullable=True), - sa.PrimaryKeyConstraint('id') + op.create_table( + "user", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("full_name", sa.String(), nullable=True), + sa.Column("email", sa.String(), nullable=True), + sa.Column("hashed_password", sa.String(), nullable=True), + sa.Column("is_active", sa.Boolean(), nullable=True), + sa.Column("is_superuser", sa.Boolean(), nullable=True), + sa.PrimaryKeyConstraint("id"), ) - op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True) - op.create_index(op.f('ix_user_full_name'), 'user', ['full_name'], unique=False) - op.create_index(op.f('ix_user_id'), 'user', ['id'], unique=False) - op.create_table('item', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('title', sa.String(), nullable=True), - sa.Column('description', sa.String(), nullable=True), - sa.Column('owner_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ), - sa.PrimaryKeyConstraint('id') + op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True) + op.create_index(op.f("ix_user_full_name"), "user", ["full_name"], unique=False) + op.create_index(op.f("ix_user_id"), "user", ["id"], unique=False) + op.create_table( + "item", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("title", sa.String(), nullable=True), + sa.Column("description", sa.String(), nullable=True), + sa.Column("owner_id", sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(["owner_id"], ["user.id"],), + sa.PrimaryKeyConstraint("id"), ) - op.create_index(op.f('ix_item_description'), 'item', ['description'], unique=False) - op.create_index(op.f('ix_item_id'), 'item', ['id'], unique=False) - op.create_index(op.f('ix_item_title'), 'item', ['title'], unique=False) + op.create_index(op.f("ix_item_description"), "item", ["description"], unique=False) + op.create_index(op.f("ix_item_id"), "item", ["id"], unique=False) + op.create_index(op.f("ix_item_title"), "item", ["title"], unique=False) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_item_title'), table_name='item') - op.drop_index(op.f('ix_item_id'), table_name='item') - op.drop_index(op.f('ix_item_description'), table_name='item') - op.drop_table('item') - op.drop_index(op.f('ix_user_id'), table_name='user') - op.drop_index(op.f('ix_user_full_name'), table_name='user') - op.drop_index(op.f('ix_user_email'), table_name='user') - op.drop_table('user') + op.drop_index(op.f("ix_item_title"), table_name="item") + op.drop_index(op.f("ix_item_id"), table_name="item") + op.drop_index(op.f("ix_item_description"), table_name="item") + op.drop_table("item") + op.drop_index(op.f("ix_user_id"), table_name="user") + op.drop_index(op.f("ix_user_full_name"), table_name="user") + op.drop_index(op.f("ix_user_email"), table_name="user") + op.drop_table("user") # ### end Alembic commands ### diff --git a/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/login.py b/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/login.py index f62d6ebb9d..0c0f9c942d 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/login.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/login.py @@ -74,7 +74,9 @@ def recover_password(email: str, db: Session = Depends(get_db)): @router.post("/reset-password/", tags=["login"], response_model=Msg) -def reset_password(token: str = Body(...), new_password: str = Body(...), db: Session = Depends(get_db)): +def reset_password( + token: str = Body(...), new_password: str = Body(...), db: Session = Depends(get_db) +): """ Reset password """ diff --git a/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/utils.py b/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/utils.py index e562e97f5c..91c074d451 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/utils.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/utils.py @@ -4,7 +4,7 @@ from app.api.utils.security import get_current_active_superuser from app.core.celery_app import celery_app from app.schemas.msg import Msg -from app.schemas.user import User +from app.schemas.user import User # noqa: F401 from app.models.user import User as DBUser from app.utils import send_test_email @@ -12,9 +12,7 @@ @router.post("/test-celery/", response_model=Msg, status_code=201) -def test_celery( - msg: Msg, current_user: DBUser = Depends(get_current_active_superuser) -): +def test_celery(msg: Msg, current_user: DBUser = Depends(get_current_active_superuser)): """ Test Celery worker. """ diff --git a/{{cookiecutter.project_slug}}/backend/app/app/core/config.py b/{{cookiecutter.project_slug}}/backend/app/app/core/config.py index 11a29d8ddc..51a32c90aa 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/core/config.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/core/config.py @@ -1,4 +1,3 @@ -import os import secrets from typing import List @@ -89,4 +88,5 @@ def get_emails_enabled(cls, v, values): class Config: case_sensitive = True + settings = Settings() diff --git a/{{cookiecutter.project_slug}}/backend/app/app/crud/__init__.py b/{{cookiecutter.project_slug}}/backend/app/app/crud/__init__.py index 20491baed7..e84e698c37 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/crud/__init__.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/crud/__init__.py @@ -1,5 +1,5 @@ -from .crud_user import user -from .crud_item import item +from .crud_user import user # noqa: F401 +from .crud_item import item # noqa: F401 # For a new basic set of CRUD operations you could just do diff --git a/{{cookiecutter.project_slug}}/backend/app/app/db/init_db.py b/{{cookiecutter.project_slug}}/backend/app/app/db/init_db.py index fd142a8d7d..4c216d2162 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/db/init_db.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/db/init_db.py @@ -5,7 +5,7 @@ # make sure all SQL Alchemy models are imported before initializing DB # otherwise, SQL Alchemy might fail to initialize relationships properly # for more details: https://github.com/tiangolo/full-stack-fastapi-postgresql/issues/28 -from app.db import base +from app.db import base # noqa: F401 def init_db(db_session): @@ -21,4 +21,4 @@ def init_db(db_session): password=settings.FIRST_SUPERUSER_PASSWORD, is_superuser=True, ) - user = crud.user.create(db_session, obj_in=user_in) + user = crud.user.create(db_session, obj_in=user_in) # noqa: F841 diff --git a/{{cookiecutter.project_slug}}/backend/app/app/schemas/item.py b/{{cookiecutter.project_slug}}/backend/app/app/schemas/item.py index dc4e382658..49ff3784d6 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/schemas/item.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/schemas/item.py @@ -1,6 +1,7 @@ from pydantic import BaseModel -from .user import User +from .user import User # noqa: F401 + # Shared properties class ItemBase(BaseModel): diff --git a/{{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/test_items.py b/{{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/test_items.py index 370c71d53e..0a6c996ff4 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/test_items.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/test_items.py @@ -3,7 +3,7 @@ from app.core.config import settings from app.tests.utils.item import create_random_item from app.tests.utils.utils import get_server_api -from app.tests.utils.user import create_random_user +from app.tests.utils.user import create_random_user # noqa: F401 def test_create_item(superuser_token_headers): diff --git a/{{cookiecutter.project_slug}}/backend/app/app/tests/crud/test_item.py b/{{cookiecutter.project_slug}}/backend/app/app/tests/crud/test_item.py index 7b9d438ddd..739aa8e0a2 100644 --- a/{{cookiecutter.project_slug}}/backend/app/app/tests/crud/test_item.py +++ b/{{cookiecutter.project_slug}}/backend/app/app/tests/crud/test_item.py @@ -55,7 +55,9 @@ def test_delete_item(): description = random_lower_string() item_in = ItemCreate(title=title, description=description) user = create_random_user() - item = crud.item.create_with_owner(db_session=db_session, obj_in=item_in, owner_id=user.id) + item = crud.item.create_with_owner( + db_session=db_session, obj_in=item_in, owner_id=user.id + ) item2 = crud.item.remove(db_session=db_session, id=item.id) item3 = crud.item.get(db_session=db_session, id=item.id) assert item3 is None