-
Notifications
You must be signed in to change notification settings - Fork 4
/
pyproject.toml
246 lines (219 loc) Β· 7.53 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
[build-system]
requires = ["hatchling >= 1.13.0", "hatch-regex-commit"]
build-backend = "hatchling.build"
# https://hatch.pypa.io/latest/config/metadata/
[project]
name = "fastapi-proxy-lib"
requires-python = ">=3.8"
readme = "README.md"
license = { file = "LICENSE" }
authors = [
{ name = "Sean Wang", email = "[email protected]" },
]
description = "HTTP/WebSocket proxy for starlette/FastAPI."
keywords = [
"proxy",
"reverse-proxy",
"forward-proxy",
"http",
"websocket",
"asgi",
"starlette",
"fastapi",
"httpx",
"httpx-ws",
]
# https://pypi.org/classifiers/
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Internet :: WWW/HTTP :: Session",
"Environment :: Web Environment",
"Framework :: AsyncIO",
"Framework :: FastAPI",
"Typing :: Typed",
]
dynamic = ["version"]
# NOTE: version constraints
# https://iscinumpy.dev/post/bound-version-constraints/
dependencies = [
"httpx",
"httpx-ws >= 0.4.2",
"starlette",
"typing_extensions >=4.5.0",
]
[project.optional-dependencies]
standard = ["fastapi"]
all = ["fastapi-proxy-lib[standard]"]
[project.urls]
Documentation = "https://WSH032.github.io/fastapi-proxy-lib/"
"Source code" = "https://github.com/WSH032/fastapi-proxy-lib"
[tool.hatch.version]
# refer to: https://github.com/frankie567/hatch-regex-commit
source = "regex_commit"
commit_extra_args = ["-e"]
path = "src/fastapi_proxy_lib/__init__.py"
# NOTE: `chore` is required by commitlint
commit_message = "chore(version): π bump version v{current_version} β v{new_version}"
tag_message = "π bump version v{current_version} β v{new_version}"
# NOTE: `v` prefix is required by github `publish.yml` action
tag_name = "v{new_version}"
check_dirty = false
[tool.hatch.envs.default]
path = ".venv" # for vscode auto selecting python interpreter
features = ["standard"] # NOTE: Don't use Self-referential
dependencies = [
# NOTE: π
# The versions of `black`, `ruff`, `codespell`, must be consistent with the `.pre-commit-config.yaml`.
# Don't edit them manually, use `pre-commit run ver_sync` instead.
"black==24.3.0",
"ruff==0.3.4",
"codespell==2.2.6",
# Don't write comments on these lines, because they will be removed by `pre-commit run ver_sync`.
# NOTE: π
# lint-check
"pyright == 1.1.356", # pyright must be installed in the runtime environment
# test
"pytest == 7.*",
"pytest-cov == 4.*",
"uvicorn[standard] < 1.0.0", # TODO: Once it releases version 1.0.0, we will remove this restriction.
"httpx[http2]", # we don't set version here, instead set it in `[project].dependencies`.
"anyio", # we don't set version here, because fastapi has a dependency on it
"asgi-lifespan==2.*",
"pytest-timeout==2.*",
]
[tool.hatch.envs.default.scripts]
# https://pytest-cov.readthedocs.io/en/latest/config.html
# xml for codecov, html for local review
test = "pytest tests/ --cov --cov-report=xml --cov-report=html"
# ruff must before black
lint = ["- ruff --fix .", "- black .", "- pyright .", "- codespell . -i 3 -w"]
lint-check = [
"ruff check .",
"black --check .",
"pyright .",
"pyright --verifytypes fastapi_proxy_lib --ignoreexternal",
"codespell .",
]
check-all = ["lint-check", "test"]
# https://hatch.pypa.io/latest/config/environment/overview/#detached-environments
[tool.hatch.envs.docs]
path = ".venv-docs"
detached = true
dependencies = [
"mkdocs-material == 9.*",
"mkdocstrings[python] == 0.24.*",
"mkdocs-gen-files == 0.5.*",
"mkdocs-literate-nav == 0.6.*",
"mkdocs-section-index == 0.3.*",
"mkdocs-git-revision-date-localized-plugin == 1.*",
"mkdocs-git-committers-plugin-2 == 2.*",
]
[tool.hatch.envs.docs.scripts]
docs-serve = "mkdocs serve"
docs-build = "mkdocs build"
# https://docs.astral.sh/ruff/rules/
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"N", # pep8-naming
"UP", # pyupgrade
"D", # pydocstyle
"SIM", # flake8-simplify
"RUF", # unused-noqa
"Q", # flake8-quotes
"C90", # McCabe complexity
"ANN001", # missing-type-function-argument
"ANN201", # missing-return-type-undocumented-public-function
"ASYNC", # flake8-async
"A", # flake8-builtins
"COM", # flake8-commas
"ISC", # flake8-implicit-str-concat
"ICN001", # unconventional-import-alias
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
"PGH004", # blanket-noqa
"TRY201", # Use raise without specifying exception name
"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PERF", # Perflint
"PL", # Pylint
"TID252", # Relative imports from parent modules are banned
]
ignore = [
"E501", # line too long, handled by black
"COM812", # missing-trailing-comma
"PERF203", # try-except within a loop incurs performance overhead
"PLR2004", # magic-value-comparison
"PLR5501", # collapsible-else-if
"PLW0120", # useless-else-on-loop
"PLR0911", # too-many-return-statements
"PLR0913", # too-many-arguments
"PLC0205", # single-string-slots
"PLW0603", # global-statement
"PLC1901", # compare-to-empty-string
"PLR0904", # too-many-public-methods
"RUF002", # ambiguous-unicode-character-docstring
"RUF003", # ambiguous-unicode-character-comment
"SIM105", # suppressible-exception # slower
# "D418", # Function decorated with `@overload` shouldn't contain a docstring
# "SIM108", # if-else-block-instead-of-if-exp
]
# https://docs.astral.sh/ruff/settings/#pydocstyle
[tool.ruff.lint.pydocstyle]
convention = "google"
# [tool.ruff.flake8-tidy-imports]
# ban-relative-imports = "all"
# https://microsoft.github.io/pyright/#/configuration
[tool.pyright]
typeCheckingMode = "strict"
pythonVersion = "3.8"
reportUnusedImport = "warning"
reportUnusedFunction = "warning"
reportUnusedExpression = "warning"
reportUnusedVariable = "warning"
reportUnnecessaryTypeIgnoreComment = true
reportPrivateUsage = "warning"
reportUnnecessaryIsInstance = "warning"
reportIncompatibleMethodOverride = "warning"
reportMissingTypeArgument = true
reportMissingParameterType = true
# https://coverage.readthedocs.io/en/7.3.2/config.html#run
[tool.coverage.run]
branch = true
source = ['fastapi_proxy_lib']
# https://coverage.readthedocs.io/en/7.3.2/config.html#report
[tool.coverage.report]
exclude_also = [
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"raise NotImplementedError",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
# # deprecated code will not be tested
"@(typing_extensions\\.)?deprecated",
# `overload` just for type hint, will not be tested
"@(typing_extensions\\.)?overload",
"@(typing\\.)?overload",
"raise AssertionError",
]
[tool.codespell]
# https://github.com/codespell-project/codespell/issues/1887
skip = "./htmlcov,./site"
[tool.pytest.ini_options]
timeout = 15