-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
154 lines (133 loc) · 3.88 KB
/
pyproject.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "fastapi-hatch-template"
version = "0.1.0"
description = "A template for FastAPI projects using Hatch for environment management and packaging, with built-in support for async operations, database migrations, and static analysis."
readme = "README.md"
requires-python = ">=3.10"
license = "MIT"
keywords = [
"asyncio",
"fastapi",
"fastapi-template",
"hatch",
"pyright",
"pytest",
"python3",
"ruff",
"sqlalchemy",
"testcontainers",
"uv",
]
authors = [{ name = "Dragos Catarahia", email = "dragos@catarahia.me" }]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"aiofiles>=24.1.0,<25.0.0",
"alembic>=1.13.2,<2.0.0",
"asyncpg>=0.29.0,<0.30.0",
"fastapi[all]>=0.111.1,<0.112.0",
"greenlet>=3.0.3,<4.0.0",
"psycopg2-binary>=2.9.9,<3.0.0",
"sqlalchemy>=2.0.31,<3.0.0",
]
[project.optional-dependencies]
# Optional dependencies for testing, linting, and hooks
test = ["anyio", "pytest", "testcontainers"]
lint = ["bandit", "pyright", "ruff"]
hooks = ["pre-commit"]
[project.urls]
# Project URLs for documentation, issues, and source code
Documentation = "https://github.com/cdragos/fastapi-hatch-template#readme"
Issues = "https://github.com/cdragos/fastapi-hatch-template/issues"
Source = "https://github.com/cdragos/fastapi-hatch-template"
[tool.hatch.envs.default]
# Default environment settings
python = "3.12"
installer = "uv"
path = ".hatch/default"
[tool.hatch.envs.default.scripts]
# Default environment scripts for development and database operations
dev = "fastapi dev {args:src/fastapi_hatch_template/main.py}"
make_migrations = "alembic revision --autogenerate"
upgrade = "alembic upgrade head"
seed_db = "python {args:src/cli.py} seed-db"
[tool.hatch.envs.default.env-vars]
# Enable AsyncIO debug mode
PYTHONASYNCIODEBUG = "1"
[tool.hatch.envs.test]
features = ["test"]
path = ".hatch/test"
[tool.hatch.envs.test.scripts]
test = "pytest {args:src/tests}"
[tool.hatch.envs.hatch-static-analysis]
features = ["lint"]
path = ".hatch/hatch_static_analysis"
[tool.hatch.envs.hatch-static-analysis.scripts]
format-check = ["ruff format --check"]
format-fix = ["ruff format"]
lint-check = [
"ruff check",
"pyright",
"bandit -c pyproject.toml -r src"
]
lint-fix = ["ruff check --fix"]
[tool.hatch.envs.hatch-static-analysis.env-vars]
# Automatically use the latest available version of Pyright
PYRIGHT_PYTHON_FORCE_VERSION = "latest"
[tool.hatch.envs.hooks]
features = ["lint", "hooks"]
path = ".hatch/hooks"
[tool.hatch.metadata]
allow-direct-references = true
[tool.ruff]
target-version = "py310"
line-length = 120
include = ["pyproject.toml", "src/**/*.py", "tests/**/*.py"]
[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # Pyflakes
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
"I", # isort
"Q", # flake8-quotes
"RUF100", # unused-noqa
"DTZ005", # https://docs.astral.sh/ruff/rules/call-datetime-now-without-tzinfo/
]
ignore = ["B008"]
[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "double"
[tool.ruff.lint.isort]
combine-as-imports = true
known-first-party = [
"fastapi",
"httpx",
"pydantic",
"pytest",
"sqlalchemy",
"testcontainers",
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.format]
docstring-code-format = true
quote-style = "single"
[tool.pyright]
include = ["src"]
venvPath = '.hatch'
venv = 'test'
reportUnsupportedDunderAll = false
[tool.bandit]
exclude_dirs = ["tests"]