-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpyproject.toml
206 lines (185 loc) · 6.04 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
[tool.poetry]
name = "fastapi-sqla"
version = "3.4.8"
description = "SQLAlchemy extension for FastAPI with support for pagination, asyncio, SQLModel, and pytest, ready for production."
authors = [
"Hadrien David <[email protected]>",
"Victor Repkow <[email protected]>",
]
license = "MIT"
readme = "README.md"
repository = "https://github.com/dialoguemd/fastapi-sqla"
keywords = ["FastAPI", "SQLAlchemy", "asyncio", "pytest", "alembic"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: AsyncIO",
"Framework :: FastAPI",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"Programming Language :: SQL",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development",
"Typing :: Typed",
]
[tool.poetry.dependencies]
python = ">=3.9,<3.14"
fastapi = ">=0.95.1,<0.116"
pydantic = ">=1,<3"
sqlalchemy = ">=1.3,<3"
structlog = ">=20,<26"
deprecated = ">=1.2,<2"
alembic = { version = ">=1.4.3,<2", optional = true }
asyncpg = { version = ">=0.28.0,<0.31.0", optional = true }
boto3 = { version = ">=1.24.74,<2", optional = true }
psycopg2 = { version = ">=2.8.6,<3", optional = true }
sqlmodel = { version = ">=0.0.14,<0.0.25", optional = true }
[tool.poetry.group.dev.dependencies]
alembic = "1.15.2"
asgi_lifespan = "2.1.0"
Faker = "37.1.0"
greenlet = "3.1.1"
httpx = "0.28.1"
mypy = { version = "1.15.0", extras = ["tests"] }
psycopg2 = { version = "2.9.10", extras = ["binary"] }
pytest = "8.3.5"
pytest-asyncio = "0.26.0"
pytest-cov = "6.1.1"
ruff = "0.11.4"
tox = "4.25.0"
[tool.poetry.extras]
asyncpg = ["asyncpg"]
aws_rds_iam = ["boto3"]
pytest_plugin = ["alembic"]
psycopg2 = ["psycopg2"]
sqlmodel = ["sqlmodel"]
[build-system]
requires = ["poetry>=1.3.0"]
build-backend = "poetry.masonry.api"
[tool.semantic_release]
version_toml = ["pyproject.toml:tool.poetry.version"]
upload_to_pypi = false
commit_message = "{version}\n\nVersion generated by python-semantic-release [ci skip]"
[tool.poetry.plugins."pytest11"]
fastapi-sqla = "fastapi_sqla._pytest_plugin"
[tool.ruff]
target-version = "py39"
[tool.ruff.lint]
select = [
"E", # pycodestyle
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"N", # pep8-naming
"D", # pydocstyle
"UP", # pyupgrade
"ASYNC", # flake8-async
"S", # flake8-bandit
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"SIM", # flake8-simplify
"TD", # flake8-todos
"ERA", # eradicate
"PL", # pylint
"RUF", # ruff
]
# Ignore some pydocstyle rules that Google convention enables
ignore = [
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
"D212",
"D415",
"B008", # Enable using functions in default function args. Easier to work with FastAPI dependencies that way
"C408", # Enable using dict/list/tuple
"PLR0911", # Disable max number of return
"PLR0912", # Disable max number of branches
"PLR0913", # Disable max number of args
"PLR0915", # Disable max number of statements
"PLR2004", # Enable magic values
"SIM105", # Allow using try - except - pass
"TD001", # Enable FIXMEs
"TD002", # Enable TODOs without author
"TD003", # Enable TODOs without issue link
"N802", # FastAPI dependency conventions is title cased
"N803", # Same as N802
"N806", # Same as N802
]
[tool.ruff.lint.extend-per-file-ignores]
"tests/*" = [
"S101", # Enable assert
"S105", # Disable passwords check
"S106", # Disable passwords check
"S608", # Allow SQL string construction
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = "tests"
norecursedirs = ".git,.venv"
xfail_strict = "true"
addopts = """
-p no:fastapi-sqla
--cov-config pyproject.toml
--cov-report term
--cov-report term-missing
"""
# https://nedbatchelder.com/blog/201810/why_warnings_is_mysterious.html
filterwarnings = ["error:.*removed in version 2.0.*:"]
[tool.pytest-watch.run]
ext = ".py, .yaml, .cfg"
[tool.coverage.run]
branch = true
omit = ["tests/*", ".venv/*"]
concurrency = ["thread", "greenlet"]
[tool.coverage.report]
skip_covered = true
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = sqlalchemy{ 1.3, 1.4, 2.0, 2.0-sqlmodel }-{ asyncpg, noasyncpg }-{aws_rds_iam, noaws_rds_iam }-pydantic{ 1, 2 }
[testenv]
passenv = CI
skip_install = true
allowlist_externals = poetry
commands_pre =
poetry install
sqlmodel: poetry install --extras "sqlmodel"
aws_rds_iam: poetry install --extras "aws_rds_iam"
asyncpg: poetry install --extras "asyncpg"
asyncpg-aws_rds_iam: poetry install --extras "asyncpg aws_rds_iam"
sqlmodel-aws_rds_iam: poetry install --extras "sqlmodel aws_rds_iam"
sqlmodel-asyncpg: poetry install --extras "sqlmodel asyncpg"
sqlmodel-asyncpg-aws_rds_iam: poetry install --extras "sqlmodel asyncpg aws_rds_iam"
sqlalchemy1.3: pip install sqlalchemy==1.3
sqlalchemy1.4: pip install sqlalchemy==1.4.52
pydantic1: pip install pydantic==1.10.16
commands =
poetry run pytest -vv --showlocals --cov . --cov-report xml --cov-report html --junitxml=test-reports/pytest/junit.xml
"""
[tool.mypy]
exclude = ["tests"]
plugins = ["sqlalchemy.ext.mypy.plugin"]
[[tool.mypy.overrides]]
module = ["asyncpg", "boto3", "deprecated"]
ignore_missing_imports = true