Skip to content

Commit fa0af20

Browse files
committed
Python code into compliance with Black Flake8 fastapi#121
1 parent 3c195c1 commit fa0af20

File tree

10 files changed

+54
-52
lines changed

10 files changed

+54
-52
lines changed

{{cookiecutter.project_slug}}/backend/app/alembic/env.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,9 @@ def run_migrations_online():
6767
6868
"""
6969
configuration = config.get_section(config.config_ini_section)
70-
configuration['sqlalchemy.url'] = get_url()
70+
configuration["sqlalchemy.url"] = get_url()
7171
connectable = engine_from_config(
72-
configuration,
73-
prefix="sqlalchemy.",
74-
poolclass=pool.NullPool,
72+
configuration, prefix="sqlalchemy.", poolclass=pool.NullPool,
7573
)
7674

7775
with connectable.connect() as connection:

{{cookiecutter.project_slug}}/backend/app/alembic/versions/d4867f3a4c0a_first_revision.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,50 @@
1010

1111

1212
# revision identifiers, used by Alembic.
13-
revision = 'd4867f3a4c0a'
13+
revision = "d4867f3a4c0a"
1414
down_revision = None
1515
branch_labels = None
1616
depends_on = None
1717

1818

1919
def upgrade():
2020
# ### commands auto generated by Alembic - please adjust! ###
21-
op.create_table('user',
22-
sa.Column('id', sa.Integer(), nullable=False),
23-
sa.Column('full_name', sa.String(), nullable=True),
24-
sa.Column('email', sa.String(), nullable=True),
25-
sa.Column('hashed_password', sa.String(), nullable=True),
26-
sa.Column('is_active', sa.Boolean(), nullable=True),
27-
sa.Column('is_superuser', sa.Boolean(), nullable=True),
28-
sa.PrimaryKeyConstraint('id')
21+
op.create_table(
22+
"user",
23+
sa.Column("id", sa.Integer(), nullable=False),
24+
sa.Column("full_name", sa.String(), nullable=True),
25+
sa.Column("email", sa.String(), nullable=True),
26+
sa.Column("hashed_password", sa.String(), nullable=True),
27+
sa.Column("is_active", sa.Boolean(), nullable=True),
28+
sa.Column("is_superuser", sa.Boolean(), nullable=True),
29+
sa.PrimaryKeyConstraint("id"),
2930
)
30-
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
31-
op.create_index(op.f('ix_user_full_name'), 'user', ['full_name'], unique=False)
32-
op.create_index(op.f('ix_user_id'), 'user', ['id'], unique=False)
33-
op.create_table('item',
34-
sa.Column('id', sa.Integer(), nullable=False),
35-
sa.Column('title', sa.String(), nullable=True),
36-
sa.Column('description', sa.String(), nullable=True),
37-
sa.Column('owner_id', sa.Integer(), nullable=True),
38-
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
39-
sa.PrimaryKeyConstraint('id')
31+
op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True)
32+
op.create_index(op.f("ix_user_full_name"), "user", ["full_name"], unique=False)
33+
op.create_index(op.f("ix_user_id"), "user", ["id"], unique=False)
34+
op.create_table(
35+
"item",
36+
sa.Column("id", sa.Integer(), nullable=False),
37+
sa.Column("title", sa.String(), nullable=True),
38+
sa.Column("description", sa.String(), nullable=True),
39+
sa.Column("owner_id", sa.Integer(), nullable=True),
40+
sa.ForeignKeyConstraint(["owner_id"], ["user.id"], ),
41+
sa.PrimaryKeyConstraint("id"),
4042
)
41-
op.create_index(op.f('ix_item_description'), 'item', ['description'], unique=False)
42-
op.create_index(op.f('ix_item_id'), 'item', ['id'], unique=False)
43-
op.create_index(op.f('ix_item_title'), 'item', ['title'], unique=False)
43+
op.create_index(op.f("ix_item_description"), "item", ["description"], unique=False)
44+
op.create_index(op.f("ix_item_id"), "item", ["id"], unique=False)
45+
op.create_index(op.f("ix_item_title"), "item", ["title"], unique=False)
4446
# ### end Alembic commands ###
4547

4648

4749
def downgrade():
4850
# ### commands auto generated by Alembic - please adjust! ###
49-
op.drop_index(op.f('ix_item_title'), table_name='item')
50-
op.drop_index(op.f('ix_item_id'), table_name='item')
51-
op.drop_index(op.f('ix_item_description'), table_name='item')
52-
op.drop_table('item')
53-
op.drop_index(op.f('ix_user_id'), table_name='user')
54-
op.drop_index(op.f('ix_user_full_name'), table_name='user')
55-
op.drop_index(op.f('ix_user_email'), table_name='user')
56-
op.drop_table('user')
51+
op.drop_index(op.f("ix_item_title"), table_name="item")
52+
op.drop_index(op.f("ix_item_id"), table_name="item")
53+
op.drop_index(op.f("ix_item_description"), table_name="item")
54+
op.drop_table("item")
55+
op.drop_index(op.f("ix_user_id"), table_name="user")
56+
op.drop_index(op.f("ix_user_full_name"), table_name="user")
57+
op.drop_index(op.f("ix_user_email"), table_name="user")
58+
op.drop_table("user")
5759
# ### end Alembic commands ###

{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/login.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ def recover_password(email: str, db: Session = Depends(get_db)):
7474

7575

7676
@router.post("/reset-password/", tags=["login"], response_model=Msg)
77-
def reset_password(token: str = Body(...), new_password: str = Body(...), db: Session = Depends(get_db)):
78-
"""
79-
Reset password
80-
"""
77+
def reset_password(
78+
token: str = Body(...), new_password: str = Body(...), db: Session = Depends(get_db)
79+
):
80+
"""
81+
Reset password
82+
"""
8183
email = verify_password_reset_token(token)
8284
if not email:
8385
raise HTTPException(status_code=400, detail="Invalid token")

{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@
44
from app.api.utils.security import get_current_active_superuser
55
from app.core.celery_app import celery_app
66
from app.schemas.msg import Msg
7-
from app.schemas.user import User
7+
from app.schemas.user import User # noqa: F401
88
from app.models.user import User as DBUser
99
from app.utils import send_test_email
1010

1111
router = APIRouter()
1212

1313

1414
@router.post("/test-celery/", response_model=Msg, status_code=201)
15-
def test_celery(
16-
msg: Msg, current_user: DBUser = Depends(get_current_active_superuser)
17-
):
15+
def test_celery(msg: Msg, current_user: DBUser = Depends(get_current_active_superuser)):
1816
"""
1917
Test Celery worker.
2018
"""

{{cookiecutter.project_slug}}/backend/app/app/core/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def getenv_boolean(var_name, default_value=False):
1919

2020
SERVER_NAME = os.getenv("SERVER_NAME")
2121
SERVER_HOST = os.getenv("SERVER_HOST")
22-
BACKEND_CORS_ORIGINS = os.getenv(
23-
"BACKEND_CORS_ORIGINS"
24-
) # a string of origins separated by commas, e.g: "http://localhost, http://localhost:4200, http://localhost:3000, http://localhost:8080, http://local.dockertoolbox.tiangolo.com"
22+
BACKEND_CORS_ORIGINS = os.getenv("BACKEND_CORS_ORIGINS")
23+
# a string of origins separated by commas, e.g:
24+
# "http://localhost, http://localhost:4200, http://localhost:3000"
2525
PROJECT_NAME = os.getenv("PROJECT_NAME")
2626
SENTRY_DSN = os.getenv("SENTRY_DSN")
2727

{{cookiecutter.project_slug}}/backend/app/app/crud/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from .crud_user import user
2-
from .crud_item import item
1+
from .crud_user import user # noqa: F401
2+
from .crud_item import item # noqa: F401
33

44
# For a new basic set of CRUD operations you could just do
55

{{cookiecutter.project_slug}}/backend/app/app/db/init_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# make sure all SQL Alchemy models are imported before initializing DB
66
# otherwise, SQL Alchemy might fail to initialize relationships properly
77
# for more details: https://github.com/tiangolo/full-stack-fastapi-postgresql/issues/28
8-
from app.db import base
8+
from app.db import base # noqa: F401
99

1010

1111
def init_db(db_session):
@@ -21,4 +21,4 @@ def init_db(db_session):
2121
password=config.FIRST_SUPERUSER_PASSWORD,
2222
is_superuser=True,
2323
)
24-
user = crud.user.create(db_session, obj_in=user_in)
24+
user = crud.user.create(db_session, obj_in=user_in) # noqa: F401

{{cookiecutter.project_slug}}/backend/app/app/schemas/item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pydantic import BaseModel
22

3-
from .user import User
3+
from .user import User # noqa: F401
44

55
# Shared properties
66
class ItemBase(BaseModel):

{{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/test_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from app.core import config
44
from app.tests.utils.item import create_random_item
55
from app.tests.utils.utils import get_server_api
6-
from app.tests.utils.user import create_random_user
6+
from app.tests.utils.user import create_random_user # noqa: F401
77

88

99
def test_create_item(superuser_token_headers):

{{cookiecutter.project_slug}}/backend/app/app/tests/crud/test_item.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def test_delete_item():
5555
description = random_lower_string()
5656
item_in = ItemCreate(title=title, description=description)
5757
user = create_random_user()
58-
item = crud.item.create_with_owner(db_session=db_session, obj_in=item_in, owner_id=user.id)
58+
item = crud.item.create_with_owner(
59+
db_session=db_session, obj_in=item_in, owner_id=user.id
60+
)
5961
item2 = crud.item.remove(db_session=db_session, id=item.id)
6062
item3 = crud.item.get(db_session=db_session, id=item.id)
6163
assert item3 is None

0 commit comments

Comments
 (0)