Checked with MyPy, Pylint; updated Pylint config
This commit is contained in:
parent
2a2175e31a
commit
a91613cbd3
7 changed files with 133 additions and 123 deletions
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@ from .common import templates
|
|||
def with_redirect(
|
||||
url: str = '/',
|
||||
code: int = 302,
|
||||
*args, **kwargs) -> RedirectResponse:
|
||||
**kwargs) -> RedirectResponse:
|
||||
"""Return a redirect to the page specified in `url`.
|
||||
By default, code is 302 so method is changed to GET.
|
||||
To leave the same HTTP method, use 307 status code
|
||||
or call `with_redirect_307` function.
|
||||
`args` and `kwargs` are passed directly
|
||||
`kwargs` are passed directly
|
||||
to the Response contructor
|
||||
|
||||
Args:
|
||||
|
@ -35,16 +35,16 @@ def with_redirect(
|
|||
return RedirectResponse(
|
||||
url=url,
|
||||
status_code=code,
|
||||
*args, **kwargs,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
def with_text(
|
||||
content: str,
|
||||
code: int = 200,
|
||||
*args, **kwargs) -> PlainTextResponse:
|
||||
**kwargs) -> PlainTextResponse:
|
||||
"""Return a plain text to the user.
|
||||
`args` and `kwargs` are passed directly
|
||||
`kwargs` are passed directly
|
||||
to the Response contructor
|
||||
|
||||
Args:
|
||||
|
@ -58,7 +58,7 @@ def with_text(
|
|||
return PlainTextResponse(
|
||||
content=content,
|
||||
status_code=code,
|
||||
*args, **kwargs,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
|
@ -117,10 +117,10 @@ def with_file(
|
|||
path: os.PathLike,
|
||||
mime: Optional[str] = None,
|
||||
code: int = 200,
|
||||
*args, **kwargs) -> FileResponse:
|
||||
**kwargs) -> FileResponse:
|
||||
"""Send the file specified in `path`
|
||||
automatically guessing its mimetype if `mime` is None.
|
||||
`args` and `kwargs` are passed directly
|
||||
`kwargs` are passed directly
|
||||
to the Response contructor
|
||||
|
||||
Args:
|
||||
|
@ -139,7 +139,7 @@ def with_file(
|
|||
mimetypes.guess_type(path)[0]
|
||||
),
|
||||
status_code=code,
|
||||
*args, **kwargs,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
|
|
0
app/sql/__init__.py
Normal file
0
app/sql/__init__.py
Normal file
|
@ -3,11 +3,12 @@ from typing import AsyncGenerator
|
|||
from pydantic import BaseSettings
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy_utils import database_exists
|
||||
from sqlalchemy_utils import create_database
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
from sqlalchemy_utils import database_exists
|
||||
from sqlalchemy_utils import create_database
|
||||
|
||||
|
||||
# Database configuration
|
||||
class SqlSettings(BaseSettings):
|
||||
|
@ -21,10 +22,12 @@ class SqlSettings(BaseSettings):
|
|||
sql_settings = SqlSettings()
|
||||
|
||||
# DB connection URL
|
||||
# pylint: disable=consider-using-f-string
|
||||
db_url = (
|
||||
'mysql://{db_user}:{db_password}@'
|
||||
'{db_host}:{db_port}/{db_database}'
|
||||
).format(**sql_settings.dict())
|
||||
# pylint: enable=consider-using-f-string
|
||||
|
||||
|
||||
# SQLAlchemy engine object
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel # pylint: disable=no-name-in-module
|
||||
|
||||
|
||||
# Pydantic class for
|
||||
|
|
Loading…
Add table
Reference in a new issue