/ fastapi-template / pyproject.toml
pyproject.toml
1 [tool.poetry] 2 name = "fastapi-template" 3 version = "0" 4 description = "" 5 authors = ["Defelo <elodef42@gmail.com>"] 6 readme = "README.md" 7 license = "GPL-3.0-only" 8 homepage = "https://github.com/Defelo/fastapi-template" 9 repository = "https://github.com/Defelo/fastapi-template" 10 packages = [{ include = "api" }] 11 12 [tool.poetry.dependencies] 13 python = "^3.10" 14 fastapi = "^0.84.0" 15 uvicorn = "^0.19.0" 16 aiohttp = "^3.8.3" 17 aioredis = "^2.0.1" 18 SQLAlchemy = "^1.4.42" 19 aiomysql = "^0.1.1" 20 asyncpg = "^0.26.0" 21 sentry-sdk = "^1.10.1" 22 pydantic = "^1.10.2" 23 httpx = "^0.23.0" 24 starlette = "^0.19.1" 25 alembic = "^1.8.1" 26 PyJWT = "^2.4.0" 27 28 [tool.poetry.group.dev.dependencies] 29 flake8 = "^4.0.1" 30 isort = "^5.10.1" 31 black = "^22.8.0" 32 wemake-python-styleguide = "^0.16.1" 33 mypy = "^0.971" 34 SQLAlchemy = { extras = ["mypy"], version = "^1.4.42" } 35 pytest = "^7.1.3" 36 coverage = "^6.4" 37 pytest-asyncio = "^0.19.0" 38 pytest-mock = "^3.8.2" 39 aiosqlite = "^0.17.0" 40 rich = "^12.5.1" 41 42 [tool.poe.tasks] 43 api = { script = "api.main:main", envfile = ".env" } 44 flake8 = "flake8 . --count --statistics --show-source" 45 isort = "isort ." 46 black = "black ." 47 format = ["isort", "black"] 48 mypy = "mypy ." 49 lint = ["format", "mypy", "flake8"] 50 test = "pytest -v tests" 51 pre-commit = ["lint", "coverage"] 52 alembic = { cmd = "alembic", envfile = ".env" } 53 migrate = { cmd = "alembic upgrade head", envfile = ".env" } 54 env = { cmd = """python -c 'from api.settings import settings; from rich import print; print(settings)'""", envfile = ".env" } 55 jwt = { cmd = """python -c 'from api.utils import jwt; import sys, json; print(jwt.encode_jwt(json.loads(sys.argv[1]), jwt.timedelta(seconds=int(sys.argv[2]))))'""", envfile = ".env" } 56 57 [tool.poe.tasks.coverage] 58 shell = """ 59 set -e 60 coverage run -m pytest -v tests 61 if [[ "$check" != True ]]; then fail="--fail-under=0"; fi 62 if ! coverage report $fail; then c=2; fi 63 if [[ "$xml" = True ]]; then coverage xml --fail-under=0; fi 64 if [[ "$html" = True ]]; then coverage html --fail-under=0 && xdg-open htmlcov/index.html; fi 65 if [[ "$clean" = True ]]; then coverage erase; fi 66 exit $c 67 """ 68 interpreter = "bash" 69 70 [tool.poe.tasks.coverage.args.xml] 71 options = ["--xml"] 72 type = "boolean" 73 74 [tool.poe.tasks.coverage.args.html] 75 options = ["--html"] 76 type = "boolean" 77 78 [tool.poe.tasks.coverage.args.clean] 79 options = ["--no-clean"] 80 type = "boolean" 81 default = true 82 83 [tool.poe.tasks.coverage.args.check] 84 options = ["--no-check"] 85 type = "boolean" 86 default = true 87 88 [tool.poe.tasks.setup] 89 shell = """ 90 set -ex 91 poetry install --sync 92 if ! [[ -e .env ]]; then cp fastapi.env .env; fi 93 ./pre-commit.sh install 94 unset VIRTUAL_ENV 95 git submodule update --init 96 git submodule foreach 'poe setup' 97 """ 98 interpreter = "bash" 99 100 [tool.black] 101 target-version = ["py310"] 102 line-length = 120 103 skip-magic-trailing-comma = true 104 105 [tool.isort] 106 profile = "black" 107 py_version = 310 108 line_length = 120 109 lines_after_imports = 2 110 reverse_relative = true 111 known_local_folder = ["api", "tests"] 112 sections = ["FUTURE", "STDLIB", "FIRSTPARTY", "THIRDPARTY", "LOCALFOLDER"] 113 114 [tool.mypy] 115 strict = true 116 ignore_missing_imports = true 117 plugins = ["sqlalchemy.ext.mypy.plugin"] 118 exclude = ['^alembic/env\.py$'] 119 120 [tool.pytest.ini_options] 121 asyncio_mode = "auto" 122 markers = [] 123 124 [tool.coverage.run] 125 branch = true 126 source = ["api"] 127 omit = ["api/__main__.py", "tests/*"] 128 concurrency = ["thread", "greenlet"] 129 130 [tool.coverage.report] 131 fail_under = 100 132 exclude_lines = ["if TYPE_CHECKING:", "if settings.debug:"] 133 134 [build-system] 135 requires = ["poetry-core>=1.0.0"] 136 build-backend = "poetry.core.masonry.api"