This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import TYPE_CHECKING, Any, Generic, Tuple, Type, TypeVar, Union | |
import numpy as np | |
from typing_extensions import Literal | |
T = TypeVar("T") | |
S = TypeVar("S") | |
class Dimension(Generic[T]): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dmypy start -- --config-file mypy.ini -m fastapi -m pydantic -m starlette ; dmypy check backend/app/app | |
[mypy] | |
plugins = sqlmypy,backend/app/pydanticmypy.py:strict | |
follow_imports = silent | |
strict_optional = True | |
warn_redundant_casts = True | |
warn_unused_ignores = True | |
disallow_any_generics = True | |
check_untyped_defs = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
from typing import Any, Callable, List, Type, TypeVar, Union, get_type_hints | |
from fastapi import APIRouter, Depends | |
from pydantic.typing import is_classvar | |
from starlette.routing import Route, WebSocketRoute | |
T = TypeVar("T") | |
CBV_CLASS_KEY = "__cbv_class__" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UserCreateT = TypeVar("UserCreateT", bound=UserCreate) | |
UserCreateRequestT = TypeVar("UserCreateRequestT", bound=UserCreateRequest) | |
UserInDBT = TypeVar("UserInDBT", bound=UserInDB) | |
UserUpdateT = TypeVar("UserUpdateT", bound=UserUpdate) | |
UserApiT = TypeVar("UserApiT", bound=UserBaseInDB) | |
UserOrmT = TypeVar("UserOrmT", bound=BaseUser) | |
logger = logging.getLogger(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DEFAULT_GOAL := default | |
app_root = backend/app | |
pkg_src = $(app_root)/app | |
tests_src = $(app_root)/tests | |
local_tests_src = $(app_root)/tests/local | |
isort = isort -rc $(pkg_src) $(tests_src) | |
black = black $(pkg_src) $(tests_src) | |
flake8 = flake8 $(pkg_src) $(tests_src) | |
mypy = mypy $(pkg_src) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Adapted from https://github.com/pybind/cmake_example | |
""" | |
import os | |
import platform | |
import re | |
import subprocess | |
import sys | |
import sysconfig | |
from distutils.version import LooseVersion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mypy] | |
plugins = pydanticmypy.py | |
follow_imports = silent | |
strict_optional = True | |
warn_redundant_casts = True | |
warn_unused_ignores = True | |
disallow_any_generics = True | |
check_untyped_defs = True | |
ignore_missing_imports = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Dict, Set, Type, TypeVar | |
from pydantic import BaseConfig, BaseModel, ConfigError, DictError, validate_model | |
from pydantic.utils import change_exception | |
Model = TypeVar("Model", bound=BaseModel) | |
class APIModel(BaseModel): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any, Dict, Generic, Optional, Tuple, Type, TypeVar, Union, get_type_hints, no_type_check | |
from pydantic import BaseModel, create_model, validator | |
from pydantic.class_validators import gather_validators | |
class BaseGenericModel: | |
def __init__(self, *args: Any, **kwargs: Any) -> None: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import lru_cache | |
from typing import Any, Dict, Generic, List, Optional, Type, TypeVar, Union | |
from pydantic import BaseModel, create_model | |
from starlette.requests import Request | |
from starlette.responses import JSONResponse | |
from fastapi import FastAPI | |
from fastapi.encoders import jsonable_encoder |