Debian Codegraph @

pyproject.toml

raw
1 [build-system]
2 build-backend = "setuptools.build_meta"
3 requires = [
4 "setuptools>=77",
5 "setuptools-scm[toml]>=6.2.3",
6 ]
7
8 [project]
9 name = "pytest"
10 description = "pytest: simple powerful testing with Python"
11 readme = "README.rst"
12 keywords = [
13 "test",
14 "unittest",
15 ]
16 license = "MIT"
17 license-files = [ "LICENSE" ]
18 authors = [
19 { name = "Brianna Laugher" },
20 { name = "Bruno Oliveira" },
21 { name = "Floris Bruynooghe" },
22 { name = "Freya Bruhin" },
23 { name = "Holger Krekel" },
24 { name = "Others (See AUTHORS)" },
25 { name = "Ronny Pfannschmidt" },
26 ]
27 requires-python = ">=3.10"
28 classifiers = [
29 "Development Status :: 6 - Mature",
30 "Intended Audience :: Developers",
31 "Operating System :: MacOS",
32 "Operating System :: Microsoft :: Windows",
33 "Operating System :: POSIX",
34 "Operating System :: Unix",
35 "Programming Language :: Python :: 3 :: Only",
36 "Programming Language :: Python :: 3.10",
37 "Programming Language :: Python :: 3.11",
38 "Programming Language :: Python :: 3.12",
39 "Programming Language :: Python :: 3.13",
40 "Programming Language :: Python :: 3.14",
41 "Programming Language :: Python :: 3.15",
42 "Topic :: Software Development :: Libraries",
43 "Topic :: Software Development :: Testing",
44 "Topic :: Utilities",
45 ]
46 dynamic = [
47 "version",
48 ]
49 dependencies = [
50 "colorama>=0.4; sys_platform=='win32'",
51 "exceptiongroup>=1; python_version<'3.11'",
52 "iniconfig>=1.0.1",
53 "packaging>=22",
54 "pluggy>=1.5,<2",
55 "pygments>=2.7.2",
56 "tomli>=1; python_version<'3.11'",
57 ]
58 optional-dependencies.dev = [
59 "argcomplete",
60 "attrs>=19.2",
61 "hypothesis>=3.56",
62 "mock",
63 "requests",
64 "setuptools",
65 "xmlschema",
66 ]
67 urls.Changelog = "https://docs.pytest.org/en/stable/changelog.html"
68 urls.Contact = "https://docs.pytest.org/en/stable/contact.html"
69 urls.Funding = "https://docs.pytest.org/en/stable/sponsor.html"
70 urls.Homepage = "https://docs.pytest.org/en/latest/"
71 urls.Source = "https://github.com/pytest-dev/pytest"
72 urls.Tracker = "https://github.com/pytest-dev/pytest/issues"
73 scripts."py.test" = "_pytest.config:_console_main"
74 scripts.pytest = "_pytest.config:_console_main"
75
76 [tool.setuptools.package-data]
77 "_pytest" = [
78 "py.typed",
79 ]
80 "pytest" = [
81 "py.typed",
82 ]
83
84 [tool.setuptools_scm]
85 write_to = "src/_pytest/_version.py"
86
87 [tool.black]
88 # See https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#t-target-version
89 target-version = [ "py310", "py311", "py312", "py313" ]
90
91 [tool.ruff]
92 target-version = "py310"
93 line-length = 88
94 src = [
95 "src",
96 ]
97 format.docstring-code-format = true
98 lint.select = [
99 "B", # bugbear
100 "D", # pydocstyle
101 "E", # pycodestyle
102 "F", # pyflakes
103 "FA100", # add future annotations
104 "I", # isort
105 "PGH004", # pygrep-hooks - Use specific rule codes when using noqa
106 "PIE", # flake8-pie
107 "PLC", # pylint convention
108 "PLE", # pylint error
109 "PLR", # pylint refactor
110 "PLR1714", # Consider merging multiple comparisons
111 "PLW", # pylint warning
112 "PYI", # flake8-pyi
113 "RUF", # ruff
114 "T100", # flake8-debugger
115 "UP", # pyupgrade
116 "W", # pycodestyle
117 ]
118 lint.ignore = [
119 # bugbear ignore
120 "B004", # Using `hasattr(x, "__call__")` to test if x is callable is unreliable.
121 "B007", # Loop control variable `i` not used within loop body
122 "B009", # Do not call `getattr` with a constant attribute value
123 "B010", # [*] Do not call `setattr` with a constant attribute value.
124 "B011", # Do not `assert False` (`python -O` removes these calls)
125 "B028", # No explicit `stacklevel` keyword argument found
126 # pydocstyle ignore
127 "D100", # Missing docstring in public module
128 "D101", # Missing docstring in public class
129 "D102", # Missing docstring in public method
130 "D103", # Missing docstring in public function
131 "D104", # Missing docstring in public package
132 "D105", # Missing docstring in magic method
133 "D106", # Missing docstring in public nested class
134 "D107", # Missing docstring in `__init__`
135 "D205", # 1 blank line required between summary line and description
136 "D209", # [*] Multi-line docstring closing quotes should be on a separate line
137 "D400", # First line should end with a period
138 "D401", # First line of docstring should be in imperative mood
139 "D402", # First line should not be the function's signature
140 "D404", # First word of the docstring should not be "This"
141 "D415", # First line should end with a period, question mark, or exclamation point
142 # pytest can do weird low-level things, and we usually know
143 # what we're doing when we use type(..) is ...
144 "E721", # Do not compare types, use `isinstance()`
145 # pylint ignore
146 "PLC0105", # `TypeVar` name "E" does not reflect its covariance;
147 "PLC0414", # Import alias does not rename original package
148 "PLC0415", # import should be at top level of package
149 "PLR0124", # Name compared with itself
150 "PLR0133", # Two constants compared in a comparison (lots of those in tests)
151 "PLR0402", # Use `from x.y import z` in lieu of alias
152 "PLR0911", # Too many return statements
153 "PLR0912", # Too many branches
154 "PLR0913", # Too many arguments in function definition
155 "PLR0915", # Too many statements
156 "PLR2004", # Magic value used in comparison
157 "PLR2044", # Line with empty comment
158 "PLR5501", # Use `elif` instead of `else` then `if`
159 "PLW0120", # remove the else and dedent its contents
160 "PLW0603", # Using the global statement
161 "PLW1641", # Does not implement the __hash__ method
162 "PLW2901", # for loop variable overwritten by assignment target
163 # ruff ignore
164 "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
165 "RUF061", # Use context-manager form of `pytest.raises()`
166 ]
167 lint.per-file-ignores."src/_pytest/_py/**/*.py" = [
168 "B",
169 "PYI",
170 ]
171 lint.per-file-ignores."src/_pytest/_version.py" = [
172 "I001",
173 ]
174 # 'Unnecessary membership test on empty collection', always voluntary in tests
175 lint.per-file-ignores."testing/**/*.py" = [ "RUF060" ]
176 # can't be disabled on a line-by-line basis in file
177 lint.per-file-ignores."testing/code/test_source.py" = [
178 "F841",
179 ]
180 lint.per-file-ignores."testing/python/approx.py" = [
181 "B015",
182 ]
183 lint.extend-safe-fixes = [
184 "UP006",
185 "UP007",
186 ]
187 lint.isort.combine-as-imports = true
188 lint.isort.force-single-line = true
189 lint.isort.force-sort-within-sections = true
190 lint.isort.known-local-folder = [
191 "pytest",
192 "_pytest",
193 ]
194 lint.isort.lines-after-imports = 2
195 lint.isort.order-by-type = false
196 lint.isort.required-imports = [
197 "from __future__ import annotations",
198 ]
199 # In order to be able to format for 88 char in ruff format
200 lint.pycodestyle.max-line-length = 120
201 lint.pydocstyle.convention = "pep257"
202 lint.pyupgrade.keep-runtime-typing = false
203
204 [tool.pylint.main]
205 # Maximum number of characters on a single line.
206 max-line-length = 120
207 disable = [
208 "abstract-method",
209 "arguments-differ",
210 "arguments-renamed",
211 "assigning-non-slot",
212 "attribute-defined-outside-init",
213 "bad-builtin",
214 "bad-classmethod-argument",
215 "bad-dunder-name",
216 "bad-mcs-method-argument",
217 "broad-exception-caught",
218 "broad-exception-raised",
219 "cell-var-from-loop", # B023 from ruff / flake8-bugbear
220 "comparison-of-constants", # disabled in ruff (PLR0133)
221 "comparison-with-callable",
222 "comparison-with-itself", # PLR0124 from ruff
223 "condition-evals-to-constant",
224 "confusing-consecutive-elif",
225 "consider-alternative-union-syntax",
226 "consider-ternary-expression",
227 "consider-using-assignment-expr",
228 "consider-using-dict-items",
229 "consider-using-from-import", # not activated by default, PLR0402 disabled in ruff
230 "consider-using-f-string",
231 "consider-using-in",
232 "consider-using-namedtuple-or-dataclass",
233 "consider-using-ternary",
234 "consider-using-tuple",
235 "consider-using-with",
236 "cyclic-import",
237 "deprecated-argument",
238 "deprecated-attribute",
239 "deprecated-class",
240 "differing-param-doc",
241 "disallowed-name", # foo / bar are used often in tests
242 "docstring-first-line-empty",
243 "duplicate-code",
244 "else-if-used", # not activated by default, PLR5501 disabled in ruff
245 "empty-comment", # not activated by default, PLR2044 disabled in ruff
246 "eq-without-hash", # PLW1641 disabled in ruff
247 "eval-used",
248 "exec-used",
249 "expression-not-assigned",
250 "fixme",
251 "global-statement", # PLW0603 disabled in ruff
252 "import-error",
253 "import-outside-toplevel", # PLC0415 disabled in ruff
254 "import-private-name",
255 "inconsistent-return-statements",
256 "invalid-bool-returned",
257 "invalid-name",
258 "invalid-repr-returned",
259 "invalid-str-returned",
260 "keyword-arg-before-vararg",
261 "line-too-long",
262 "magic-value-comparison", # not activated by default, PLR2004 disabled in ruff
263 "method-hidden",
264 "misplaced-bare-raise", # PLE0704 from ruff
265 "misplaced-comparison-constant",
266 "missing-docstring",
267 "missing-param-doc",
268 "missing-raises-doc",
269 "missing-timeout",
270 "missing-type-doc",
271 "multiple-statements", # multiple-statements-on-one-line-colon (E701) from ruff
272 "no-else-break",
273 "no-else-continue",
274 "no-else-raise",
275 "no-else-return",
276 "no-member",
277 "no-name-in-module",
278 "no-self-argument",
279 "no-self-use",
280 "not-an-iterable",
281 "not-callable",
282 "pointless-exception-statement", # https://github.com/pytest-dev/pytest/pull/12379
283 "pointless-statement", # https://github.com/pytest-dev/pytest/pull/12379
284 "pointless-string-statement", # https://github.com/pytest-dev/pytest/pull/12379
285 "possibly-used-before-assignment",
286 "protected-access",
287 "raise-missing-from",
288 "redefined-argument-from-local",
289 "redefined-builtin",
290 "redefined-loop-name", # PLW2901 disabled in ruff
291 "redefined-outer-name",
292 "redefined-variable-type",
293 "reimported",
294 "simplifiable-condition",
295 "simplifiable-if-expression",
296 "singleton-comparison",
297 "superfluous-parens",
298 "super-init-not-called",
299 "too-complex",
300 "too-few-public-methods",
301 "too-many-ancestors",
302 "too-many-arguments", # disabled in ruff
303 "too-many-branches", # disabled in ruff
304 "too-many-function-args",
305 "too-many-instance-attributes",
306 "too-many-lines",
307 "too-many-locals",
308 "too-many-nested-blocks",
309 "too-many-positional-arguments",
310 "too-many-public-methods",
311 "too-many-return-statements", # disabled in ruff
312 "too-many-statements", # disabled in ruff
313 "too-many-try-statements",
314 "try-except-raise",
315 "typevar-name-incorrect-variance", # PLC0105 disabled in ruff
316 "unbalanced-tuple-unpacking",
317 "undefined-loop-variable",
318 "undefined-variable",
319 "unexpected-keyword-arg",
320 "unidiomatic-typecheck",
321 "unnecessary-comprehension",
322 "unnecessary-dunder-call",
323 "unnecessary-lambda",
324 "unnecessary-lambda-assignment",
325 "unpacking-non-sequence",
326 "unspecified-encoding",
327 "unsubscriptable-object",
328 "unused-argument",
329 "unused-import",
330 "unused-variable",
331 "used-before-assignment",
332 "use-dict-literal",
333 "use-implicit-booleaness-not-comparison",
334 "use-implicit-booleaness-not-len",
335 "useless-else-on-loop", # PLC0414 disabled in ruff
336 "useless-import-alias",
337 "useless-return",
338 "use-set-for-membership",
339 "using-constant-test",
340 "while-used",
341 "wrong-import-order", # handled by isort / ruff
342 "wrong-import-position", # handled by isort / ruff
343 ]
344
345 [tool.codespell]
346 ignore-words-list = "afile,asend,asser,assertio,feld,hove,ned,noes,notin,paramete,parth,tesults,varius,wil"
347 skip = "AUTHORS,*/plugin_list.rst"
348 write-changes = true
349
350 [tool.check-wheel-contents]
351 # check-wheel-contents is executed by the build-and-inspect-python-package action.
352 # W009: Wheel contains multiple toplevel library entries
353 ignore = "W009"
354
355 [tool.pyproject-fmt]
356 indent = 4
357 max_supported_python = "3.15"
358
359 [tool.pytest]
360 minversion = "2.0"
361 addopts = [ "-rfEX", "-p", "pytester" ]
362 python_files = [
363 "test_*.py",
364 "*_test.py",
365 "testing/python/*.py",
366 ]
367 python_classes = [
368 "Test",
369 "Acceptance",
370 ]
371 python_functions = [
372 "test",
373 ]
374 # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting".
375 testpaths = [
376 "testing",
377 ]
378 norecursedirs = [
379 "testing/example_scripts",
380 "testing/plugins_integration",
381 ".*",
382 "build",
383 "dist",
384 ]
385 strict = true
386 filterwarnings = [
387 'error',
388 'default:Using or importing the ABCs:DeprecationWarning:unittest2.*',
389 # produced by older pyparsing<=2.2.0.
390 'default:Using or importing the ABCs:DeprecationWarning:pyparsing.*',
391 'default:the imp module is deprecated in favour of importlib:DeprecationWarning:nose.*',
392 # distutils is deprecated in 3.10, scheduled for removal in 3.12
393 'ignore:The distutils package is deprecated:DeprecationWarning',
394 # produced by pytest-xdist
395 'ignore:.*type argument to addoption.*:DeprecationWarning',
396 # produced on execnet (pytest-xdist)
397 'ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning',
398 # pytest's own futurewarnings
399 'ignore::pytest.PytestExperimentalApiWarning',
400 # Do not cause SyntaxError for invalid escape sequences in py37.
401 # Those are caught/handled by pyupgrade, and not easy to filter with the
402 # module being the filename (with .py removed).
403 'default:invalid escape sequence:DeprecationWarning',
404 # ignore not yet fixed warnings for hook markers
405 'default:.*not marked using pytest.hook.*',
406 'ignore:.*not marked using pytest.hook.*::xdist.*',
407 # ignore use of unregistered marks, because we use many to test the implementation
408 'ignore::_pytest.warning_types.PytestUnknownMarkWarning',
409 # https://github.com/benjaminp/six/issues/341
410 'ignore:_SixMetaPathImporter\.exec_module\(\) not found; falling back to load_module\(\):ImportWarning',
411 # https://github.com/benjaminp/six/pull/352
412 'ignore:_SixMetaPathImporter\.find_spec\(\) not found; falling back to find_module\(\):ImportWarning',
413 # https://github.com/pypa/setuptools/pull/2517
414 'ignore:VendorImporter\.find_spec\(\) not found; falling back to find_module\(\):ImportWarning',
415 # https://github.com/pytest-dev/execnet/pull/127
416 'ignore:isSet\(\) is deprecated, use is_set\(\) instead:DeprecationWarning',
417 # https://github.com/pytest-dev/pytest/issues/2366
418 # https://github.com/pytest-dev/pytest/pull/13057
419 'default::pytest.PytestFDWarning',
420 # https://github.com/pexpect/pexpect/issues/827
421 'ignore:.*use of forkpty\(\) may lead to deadlocks in the child:DeprecationWarning:ptyprocess.*',
422 ]
423 pytester_example_dir = "testing/example_scripts"
424 markers = [
425 # dummy markers for testing
426 "foo",
427 "bar",
428 "baz",
429 "number_mark",
430 "builtin_matchers_mark",
431 "str_mark",
432 # conftest.py reorders tests moving slow ones to the end of the list
433 "slow",
434 # experimental mark for all tests using pexpect
435 "uses_pexpect",
436 # Disables the `remove_ci_env_var` autouse fixture on a given test that
437 # actually inspects whether the CI environment variable is set.
438 "keep_ci_var",
439 ]
440
441 [tool.coverage.paths]
442 source = [
443 'src/',
444 '*/lib/python*/site-packages/',
445 '*/pypy*/site-packages/',
446 '*\Lib\site-packages\',
447 ]
448
449 [tool.coverage.report]
450 skip_covered = true
451 show_missing = true
452 exclude_lines = [
453 '\#\s*pragma: no cover',
454 '^\s*raise NotImplementedError\b',
455 '^\s*return NotImplemented\b',
456 '^\s*assert False(,|$)',
457 '^\s*case unreachable:',
458 '^\s*assert_never\(',
459 '^\s*if TYPE_CHECKING:',
460 '^\s*(el)?if TYPE_CHECKING:',
461 '^\s*@overload( |$)',
462 '^\s*def .+: \.\.\.$',
463 '^\s*@pytest\.mark\.xfail',
464 ]
465
466 [tool.coverage.run]
467 include = [
468 'src/*',
469 'testing/*',
470 '*/lib/python*/site-packages/_pytest/*',
471 '*/lib/python*/site-packages/pytest.py',
472 '*/pypy*/site-packages/_pytest/*',
473 '*/pypy*/site-packages/pytest.py',
474 '*\Lib\site-packages\_pytest\*',
475 '*\Lib\site-packages\pytest.py',
476 ]
477 parallel = true
478 branch = true
479 patch = [ "subprocess" ]
480 # The sysmon core (default since Python 3.14) is much slower.
481 # Perhaps: https://github.com/coveragepy/coveragepy/issues/2082
482 core = "ctrace"
483
484 [tool.towncrier]
485 package = "pytest"
486 package_dir = "src"
487 filename = "doc/en/changelog.rst"
488 directory = "changelog/"
489 title_format = "pytest {version} ({project_date})"
490 template = "changelog/_template.rst"
491
492 # NOTE: The types are declared because:
493 # NOTE: - there is no mechanism to override just the value of
494 # NOTE: `tool.towncrier.type.misc.showcontent`;
495 # NOTE: - and, we want to declare extra non-default types for
496 # NOTE: clarity and flexibility.
497
498 [[tool.towncrier.type]]
499 # When something public gets removed in a breaking way. Could be
500 # deprecated in an earlier release.
501 directory = "breaking"
502 name = "Removals and backward incompatible breaking changes"
503 showcontent = true
504
505 [[tool.towncrier.type]]
506 # Declarations of future API removals and breaking changes in behavior.
507 directory = "deprecation"
508 name = "Deprecations (removal in next major release)"
509 showcontent = true
510
511 [[tool.towncrier.type]]
512 # New behaviors, public APIs. That sort of stuff.
513 directory = "feature"
514 name = "New features"
515 showcontent = true
516
517 [[tool.towncrier.type]]
518 # New behaviors in existing features.
519 directory = "improvement"
520 name = "Improvements in existing functionality"
521 showcontent = true
522
523 [[tool.towncrier.type]]
524 # Something we deemed an improper undesired behavior that got corrected
525 # in the release to match pre-agreed expectations.
526 directory = "bugfix"
527 name = "Bug fixes"
528 showcontent = true
529
530 [[tool.towncrier.type]]
531 # Updates regarding bundling dependencies.
532 directory = "vendor"
533 name = "Vendored libraries"
534 showcontent = true
535
536 [[tool.towncrier.type]]
537 # Notable updates to the documentation structure or build process.
538 directory = "doc"
539 name = "Improved documentation"
540 showcontent = true
541
542 [[tool.towncrier.type]]
543 # Notes for downstreams about unobvious side effects and tooling. Changes
544 # in the test invocation considerations and runtime assumptions.
545 directory = "packaging"
546 name = "Packaging updates and notes for downstreams"
547 showcontent = true
548
549 [[tool.towncrier.type]]
550 # Stuff that affects the contributor experience. e.g. Running tests,
551 # building the docs, setting up the development environment.
552 directory = "contrib"
553 name = "Contributor-facing changes"
554 showcontent = true
555
556 [[tool.towncrier.type]]
557 # Changes that are hard to assign to any of the above categories.
558 directory = "misc"
559 name = "Miscellaneous internal changes"
560 showcontent = true
561
562 [tool.mypy]
563 files = [
564 "src",
565 "testing",
566 "scripts",
567 ]
568 mypy_path = [
569 "src",
570 ]
571 python_version = "3.10"
572 check_untyped_defs = true
573 disallow_any_generics = true
574 disallow_untyped_defs = true
575 ignore_missing_imports = true
576 show_error_codes = true
577 strict_equality = true
578 warn_redundant_casts = true
579 warn_return_any = true
580 warn_unreachable = true
581 warn_unused_configs = true
582 no_implicit_reexport = true
583 warn_unused_ignores = true
584 enable_error_code = [ "deprecated" ]
585
586 [tool.pyright]
587 include = [
588 "src",
589 "testing",
590 "scripts",
591 ]
592 extraPaths = [
593 "src",
594 ]
595 pythonVersion = "3.10"
596 typeCheckingMode = "basic"
597 reportMissingImports = "none"
598 reportMissingModuleSource = "none"