-
Notifications
You must be signed in to change notification settings - Fork 137
/
pyproject.toml
362 lines (315 loc) · 10.3 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
[project]
name = "pact-python"
description = "Tool for creating and verifying consumer-driven contracts using the Pact framework."
dynamic = ["version"]
authors = [
{ name = "Matthew Balvanz", email = "[email protected]" },
{ name = "Joshua Ellis", email = "[email protected]" },
]
maintainers = [{ name = "Joshua Ellis", email = "[email protected]" }]
readme = "README.md"
license = { file = "LICENSE" }
keywords = ["pact", "contract-testing", "testing"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Testing",
]
requires-python = ">=3.9"
# Dependencies of Pact Python should be specified using the broadest range
# compatible version unless:
#
# - A specific feature is required in a new minor release
# - A minor version address vulnerability which directly impacts Pact Python
dependencies = [
"cffi ~=1.0",
"click ~=8.0",
"fastapi ~=0.0",
"psutil ~=6.0",
"requests ~=2.0",
"six ~=1.0",
"typing-extensions ~=4.0 ; python_version < '3.10'",
"uvicorn ~=0.0",
"yarl ~=1.0",
]
[project.urls]
"Homepage" = "https://pact.io"
"Repository" = "https://github.com/pact-foundation/pact-python"
"Documentation" = "https://docs.pact.io"
"Bug Tracker" = "https://github.com/pact-foundation/pact-python/issues"
"Changelog" = "https://github.com/pact-foundation/pact-python/blob/main/CHANGELOG.md"
[project.scripts]
pact-verifier = "pact.cli.verify:main"
[project.optional-dependencies]
# Linting and formatting tools use a more narrow specification to ensure
# developper consistency. All other dependencies are as above.
devel-types = [
"mypy ==1.13.0",
"types-cffi ~=1.0",
"types-requests ~=2.0",
]
devel-docs = [
"mkdocs ~= 1.5",
"mkdocs-material[imaging] ~= 9.4",
"mkdocs_gen_files ~= 0.5",
"mkdocs-literate-nav ~= 0.6",
"mkdocs-section-index ~= 0.3",
"mkdocstrings[python] ~= 0.23",
]
devel-test = [
"aiohttp[speedups] ~=3.0",
"coverage[toml] ~=7.0",
"flask[async] ~=3.0",
"httpx ~=0.0",
"mock ~=5.0",
"pytest ~=8.0",
"pytest-asyncio ~=0.0",
"pytest-bdd ~=8.0",
"pytest-cov ~=6.0",
"testcontainers ~=4.0",
]
devel = ["pact-python[devel-types,devel-docs,devel-test]", "ruff==0.8.1"]
################################################################################
## Hatch Build Configuration
################################################################################
[build-system]
requires = [
"cffi",
"hatch-vcs",
"hatchling",
"packaging",
"requests",
"setuptools ; python_version >= '3.12'",
]
build-backend = "hatchling.build"
[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "src/pact/__version__.py"
[tool.hatch.build.targets.sdist]
include = [
# Source
"/src/pact/**/*.py",
"/src/pact/**/*.pyi",
"/src/pact/**/py.typed",
# Metadata
"*.md",
"LICENSE",
]
[tool.hatch.build.targets.wheel]
packages = ["/src/pact"]
include = [
# Source
"/src/pact/**/*.py",
"/src/pact/**/*.pyi",
"/src/pact/**/py.typed",
]
artifacts = [
"/src/pact/bin/*", # Ruby executables
"/src/pact/lib/*", # Ruby library
"/src/pact/v3/_ffi.*", # Rust library
]
[tool.hatch.build.targets.wheel.hooks.custom]
################################################################################
## Hatch Environment Configuration
################################################################################
# Install dev dependencies in the default environment to simplify the developer
# workflow.
[tool.hatch.envs.default]
installer = "uv"
features = ["devel"]
extra-dependencies = [
"hatchling",
"packaging",
"requests",
"cffi",
"setuptools ; python_version >= '3.12'",
]
[tool.hatch.envs.default.scripts]
lint = "ruff check --output-format=full --show-fixes {args}"
typecheck = "mypy {args:.}"
format = "ruff format {args}"
test = "pytest tests/ {args}"
example = "pytest examples/ {args}"
all = ["format", "lint", "typecheck", "test", "example"]
docs = "mkdocs serve {args}"
docs-build = "mkdocs build {args}"
# Test environment for running unit tests. This automatically tests against all
# supported Python versions.
[tool.hatch.envs.test]
installer = "uv"
features = ["devel-test"]
[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
################################################################################
## PyTest Configuration
################################################################################
[tool.pytest.ini_options]
pythonpath = "."
asyncio_default_fixture_loop_scope = "session"
addopts = [
"--import-mode=importlib",
"--cov-config=pyproject.toml",
"--cov=pact",
"--cov-report=xml",
]
filterwarnings = [
"ignore::DeprecationWarning:examples",
"ignore::DeprecationWarning:pact",
"ignore::DeprecationWarning:tests",
"ignore::PendingDeprecationWarning:examples",
"ignore::PendingDeprecationWarning:pact",
"ignore::PendingDeprecationWarning:tests",
]
log_level = "NOTSET"
log_format = "%(asctime)s.%(msecs)03d [%(levelname)-8s] %(name)s: %(message)s"
log_date_format = "%H:%M:%S"
markers = [
# Marker for tests that require a container
"container",
# Markers for the compatibility suite
"consumer",
"provider",
"message",
]
################################################################################
## Coverage
################################################################################
[tool.coverage.paths]
pact = ["/src/pact"]
tests = ["/examples", "/tests"]
[tool.coverage.report]
exclude_lines = [
"if __name__ == .__main__.:", # Ignore non-runnable code
"if TYPE_CHECKING:", # Ignore typing
"raise NotImplementedError", # Ignore defensive assertions
"@(abc\\.)?abstractmethod", # Ignore abstract methods
]
################################################################################
## Ruff Configuration
################################################################################
[tool.ruff]
# TODO: Remove the explicity extend-exclude once astral-sh/ruff#6262 is fixed.
# https://github.com/pact-foundation/pact-python/issues/458
extend-exclude = [
# "src/pact/*.py",
# "src/pact/cli/*.py",
# "src/tests/*.py",
# "src/tests/cli/*.py",
"src/pact/__init__.py",
"src/pact/__version__.py",
"src/pact/broker.py",
"src/pact/cli/*.py",
"src/pact/constants.py",
"src/pact/consumer.py",
"src/pact/http_proxy.py",
"src/pact/matchers.py",
"src/pact/message_consumer.py",
"src/pact/message_pact.py",
"src/pact/message_provider.py",
"src/pact/pact.py",
"src/pact/provider.py",
"src/pact/verifier.py",
"src/pact/verify_wrapper.py",
"tests/__init__.py",
"tests/cli/*.py",
"tests/conftest.py",
"tests/test_broker.py",
"tests/test_constants.py",
"tests/test_consumer.py",
"tests/test_http_proxy.py",
"tests/test_matchers.py",
"tests/test_message_consumer.py",
"tests/test_message_pact.py",
"tests/test_message_provider.py",
"tests/test_pact.py",
"tests/test_verifier.py",
"tests/test_verify_wrapper.py",
]
[tool.ruff.lint]
select = ["ALL"]
ignore = [
"D200", # Require single line docstrings to be on one line.
"D203", # Require blank line before class docstring
"D212", # Multi-line docstring summary must start at the first line
"FIX002", # Forbid TODO in comments
"TD002", # Assign someone to 'TODO' comments
# The following are disabled for compatibility with the formatter
"COM812", # enforce trailing commas
"ISC001", # require imports to be sorted
]
[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.isort]
known-first-party = ["pact"]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
[tool.ruff.format]
preview = true
docstring-code-format = true
################################################################################
## Mypy Configuration
################################################################################
[tool.mypy]
exclude = '^(src/pact|tests|examples|examples/tests)/(?!v3).+\.py$'
################################################################################
## CI Build Wheel
################################################################################
[tool.cibuildwheel]
skip = "pp*"
before-build = """
rm -rvf src/pact/v3/bin
rm -rvf src/pact/v3/data
rm -rvf src/pact/v3/lib
mv -v src/pact/v3/_ffi.pyi _ffi.pyi
rm -rvf src/pact/v3/_ffi.*
mv -v _ffi.pyi src/pact/v3/_ffi.pyi
"""
test-command = """
python -c \
"from pact import EachLike; \
assert \
EachLike(1).generate() \
== {'json_class': 'Pact::ArrayLike', 'contents': 1, 'min': 1}; \
import pact.v3.ffi; \
assert isinstance(pact.v3.ffi.version(), str);\""""
[tool.cibuildwheel.macos]
# The repair tool unfortunately did not like the bundled Ruby distributable.
# TODO: Check whether delocate-wheel can be configured.
repair-wheel-command = ""
[tool.cibuildwheel.windows]
before-build = [
'FOR /R src\pact\v3 %G IN (_ffi.*) DO IF NOT %~nxG == _ffi.pyi DEL /F /Q "%G"',
'IF EXIST src\pact\v3\bin\ RMDIR /S /Q src\pact\v3\bin',
'IF EXIST src\pact\v3\data\ RMDIR /S /Q src\pact\v3\data',
'IF EXIST src\pact\v3\lib\ RMDIR /S /Q src\pact\v3\lib',
]
################################################################################
## Typos
################################################################################
[tool.typos.default]
extend-ignore-re = [
"(?Rm)^.*(#|//|<!--)\\s*spellchecker:\\s*ignore"
]
################################################################################
## Yamlfix
################################################################################
[tool.yamlfix]
line_length = 100
whitelines = 1
section_whitelines = 1
sequence_style = "block_style"