Skip to content

Commit 773548c

Browse files
committed
move SA stubs to dev, add few typings, a bit better python code style here and there
1 parent 995316e commit 773548c

File tree

8 files changed

+15
-27
lines changed

8 files changed

+15
-27
lines changed

{{cookiecutter.project_name}}/app/api/deps.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,3 @@ async def get_current_user(
4242
if not user:
4343
raise HTTPException(status_code=404, detail="User not found")
4444
return user
45-
46-
47-
async def get_current_active_user(
48-
current_user: User = Depends(get_current_user),
49-
) -> User:
50-
return current_user

{{cookiecutter.project_name}}/app/api/endpoints/users.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Any
2-
31
from fastapi import APIRouter, Depends
42
from sqlalchemy.ext.asyncio import AsyncSession
53

@@ -14,8 +12,8 @@
1412
async def update_user_me(
1513
user_update: schemas.UserUpdate,
1614
session: AsyncSession = Depends(deps.get_session),
17-
current_user: models.User = Depends(deps.get_current_active_user),
18-
) -> Any:
15+
current_user: models.User = Depends(deps.get_current_user),
16+
):
1917
"""
2018
Update current user.
2119
"""
@@ -35,8 +33,8 @@ async def update_user_me(
3533

3634
@router.get("/me", response_model=schemas.User)
3735
async def read_user_me(
38-
current_user: models.User = Depends(deps.get_current_active_user),
39-
) -> Any:
36+
current_user: models.User = Depends(deps.get_current_user),
37+
):
4038
"""
4139
Get current user.
4240
"""

{{cookiecutter.project_name}}/app/core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Settings(BaseSettings):
6464

6565
# VALIDATORS
6666
@validator("BACKEND_CORS_ORIGINS")
67-
def _assemble_cors_origins(cls, cors_origins):
67+
def _assemble_cors_origins(cls, cors_origins: Union[str, List[AnyHttpUrl]]):
6868
if isinstance(cors_origins, str):
6969
return [item.strip() for item in cors_origins.split(",")]
7070
return cors_origins

{{cookiecutter.project_name}}/app/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from app.core.config import settings
55

66
if settings.ENVIRONMENT == "PYTEST":
7-
SQLALCHEMY_DATABASE_URI = settings.TEST_SQLALCHEMY_DATABASE_URI
7+
sqlalchemy_database_uri = settings.TEST_SQLALCHEMY_DATABASE_URI
88
else:
9-
SQLALCHEMY_DATABASE_URI = settings.DEFAULT_SQLALCHEMY_DATABASE_URI
9+
sqlalchemy_database_uri = settings.DEFAULT_SQLALCHEMY_DATABASE_URI
1010

11-
async_engine = create_async_engine(SQLALCHEMY_DATABASE_URI, pool_pre_ping=True)
11+
async_engine = create_async_engine(sqlalchemy_database_uri, pool_pre_ping=True)
1212
async_session = sessionmaker(async_engine, expire_on_commit=False, class_=AsyncSession)

{{cookiecutter.project_name}}/app/tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import string
33

44

5-
def random_lower_string(length=32) -> str:
5+
def random_lower_string(length: int = 32) -> str:
66
return "".join(random.choices(string.ascii_lowercase, k=length))
77

88

9-
def random_email(length=10) -> str:
9+
def random_email(length: int = 10) -> str:
1010
return f"{random_lower_string(length)}@{random_lower_string(length)}.com"

{{cookiecutter.project_name}}/poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

{{cookiecutter.project_name}}/pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@ passlib = {version = "^1.7.4", extras = ["bcrypt"]}
1616
pydantic = {version = "^1.8.2", extras = ["email"]}
1717
alembic = "^1.7.3"
1818
python-multipart = "^0.0.5"
19-
sqlalchemy2-stubs = "^0.0.2-alpha.18"
2019
asyncpg = "^0.24.0"
2120

2221
[tool.poetry.dev-dependencies]
2322
black = {version = "^21.9b0", python = ">=3.6.2,<4.0.0"}
2423
autoflake = "^1.4"
2524
flake8 = "^3.9.2"
2625
isort = "^5.9.3"
27-
sqlalchemy-stubs = "^0.4"
2826
coverage = "^5.5"
2927
pytest = "^6.2.5"
30-
mypy = "^0.910"
3128
pytest-asyncio = "^0.16.0"
3229
httpx = "^0.20.0"
30+
sqlalchemy-stubs = "^0.4"
31+
sqlalchemy2-stubs = "^0.0.2-alpha.19"
3332

3433
[build-system]
3534
requires = ["poetry-core>=1.0.0"]

{{cookiecutter.project_name}}/requirements.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,6 @@ rsa==4.7.2; python_version >= "3.5" and python_version < "4" \
306306
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.3.0" \
307307
--hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 \
308308
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926
309-
sqlalchemy2-stubs==0.0.2a19; python_version >= "3.6" \
310-
--hash=sha256:2117c48ce5acfe33bf9c9bfce2a981632d931949e68fa313aa5c2a3bc980ca7a \
311-
--hash=sha256:aac7dca77a2c49e5f0934976421d5e25ae4dc5e27db48c01e055f81caa1e3ead
312309
sqlalchemy==1.4.26; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0") \
313310
--hash=sha256:c2f2114b0968a280f94deeeaa31cfbac9175e6ac7bd3058b3ce6e054ecd762b3 \
314311
--hash=sha256:91efbda4e6d311812f23996242bad7665c1392209554f8a31ec6db757456db5c \
@@ -349,7 +346,7 @@ sqlalchemy==1.4.26; (python_version >= "2.7" and python_full_version < "3.0.0")
349346
starlette==0.14.2; python_version >= "3.6" and python_full_version >= "3.6.1" \
350347
--hash=sha256:3c8e48e52736b3161e34c9f0e8153b4f32ec5d8995a3ee1d59410d92f75162ed \
351348
--hash=sha256:7d49f4a27f8742262ef1470608c59ddbc66baf37c148e938c7038e6bc7a998aa
352-
typing-extensions==3.10.0.2; python_version < "3.8" and python_full_version >= "3.6.1" and python_version >= "3.6" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.6") \
349+
typing-extensions==3.10.0.2; python_version < "3.8" and python_full_version >= "3.6.1" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.6") and python_version >= "3.6" \
353350
--hash=sha256:d8226d10bc02a29bcc81df19a26e56a9647f8b0a6d4a83924139f4a8b01f17b7 \
354351
--hash=sha256:f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34 \
355352
--hash=sha256:49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e

0 commit comments

Comments
 (0)