Skip to content

Bring Python code into compliance with Black and Flake8 #121

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

Merged
merged 4 commits into from
Apr 17, 2020
Merged
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
6 changes: 2 additions & 4 deletions {{cookiecutter.project_slug}}/backend/app/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""First revision

Revision ID: d4867f3a4c0a
Revises:
Revises:
Create Date: 2019-04-17 13:53:32.978401

"""
Expand All @@ -10,48 +10,50 @@


# revision identifiers, used by Alembic.
revision = 'd4867f3a4c0a'
revision = "d4867f3a4c0a"
down_revision = None
branch_labels = None
depends_on = None


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 ###
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
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

router = APIRouter()


@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.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import secrets
from typing import List

Expand Down Expand Up @@ -89,4 +88,5 @@ def get_emails_enabled(cls, v, values):
class Config:
case_sensitive = True


settings = Settings()
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/backend/app/app/db/init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pydantic import BaseModel

from .user import User
from .user import User # noqa: F401


# Shared properties
class ItemBase(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down