Skip to content

Commit c5ae88f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 30cae01 commit c5ae88f

File tree

3 files changed

+117
-158
lines changed

3 files changed

+117
-158
lines changed

pyproject.toml

Lines changed: 112 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ urls.Tracker = "https://github.com/pytest-dev/pytest/issues"
7272
scripts."py.test" = "pytest:console_main"
7373
scripts.pytest = "pytest:console_main"
7474

75-
[tool.setuptools.package-data]
76-
"_pytest" = [
75+
[tool.setuptools]
76+
package-data."_pytest" = [
7777
"py.typed",
7878
]
79-
"pytest" = [
79+
package-data."pytest" = [
8080
"py.typed",
8181
]
8282

@@ -116,31 +116,31 @@ lint.select = [
116116
]
117117
lint.ignore = [
118118
# bugbear ignore
119-
"B004", # Using `hasattr(x, "__call__")` to test if x is callable is unreliable.
120-
"B007", # Loop control variable `i` not used within loop body
121-
"B009", # Do not call `getattr` with a constant attribute value
122-
"B010", # [*] Do not call `setattr` with a constant attribute value.
123-
"B011", # Do not `assert False` (`python -O` removes these calls)
124-
"B028", # No explicit `stacklevel` keyword argument found
119+
"B004", # Using `hasattr(x, "__call__")` to test if x is callable is unreliable.
120+
"B007", # Loop control variable `i` not used within loop body
121+
"B009", # Do not call `getattr` with a constant attribute value
122+
"B010", # [*] Do not call `setattr` with a constant attribute value.
123+
"B011", # Do not `assert False` (`python -O` removes these calls)
124+
"B028", # No explicit `stacklevel` keyword argument found
125125
# pydocstyle ignore
126-
"D100", # Missing docstring in public module
127-
"D101", # Missing docstring in public class
128-
"D102", # Missing docstring in public method
129-
"D103", # Missing docstring in public function
130-
"D104", # Missing docstring in public package
131-
"D105", # Missing docstring in magic method
132-
"D106", # Missing docstring in public nested class
133-
"D107", # Missing docstring in `__init__`
134-
"D205", # 1 blank line required between summary line and description
135-
"D209", # [*] Multi-line docstring closing quotes should be on a separate line
136-
"D400", # First line should end with a period
137-
"D401", # First line of docstring should be in imperative mood
138-
"D402", # First line should not be the function's signature
139-
"D404", # First word of the docstring should not be "This"
140-
"D415", # First line should end with a period, question mark, or exclamation point
126+
"D100", # Missing docstring in public module
127+
"D101", # Missing docstring in public class
128+
"D102", # Missing docstring in public method
129+
"D103", # Missing docstring in public function
130+
"D104", # Missing docstring in public package
131+
"D105", # Missing docstring in magic method
132+
"D106", # Missing docstring in public nested class
133+
"D107", # Missing docstring in `__init__`
134+
"D205", # 1 blank line required between summary line and description
135+
"D209", # [*] Multi-line docstring closing quotes should be on a separate line
136+
"D400", # First line should end with a period
137+
"D401", # First line of docstring should be in imperative mood
138+
"D402", # First line should not be the function's signature
139+
"D404", # First word of the docstring should not be "This"
140+
"D415", # First line should end with a period, question mark, or exclamation point
141141
# pytest can do weird low-level things, and we usually know
142142
# what we're doing when we use type(..) is ...
143-
"E721", # Do not compare types, use `isinstance()`
143+
"E721", # Do not compare types, use `isinstance()`
144144
# pylint ignore
145145
"PLC0105", # `TypeVar` name "E" does not reflect its covariance;
146146
"PLC0414", # Import alias does not rename original package
@@ -160,7 +160,7 @@ lint.ignore = [
160160
"PLW1641", # Does not implement the __hash__ method
161161
"PLW2901", # for loop variable overwritten by assignment target
162162
# ruff ignore
163-
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
163+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
164164
]
165165
lint.per-file-ignores."src/_pytest/_py/**/*.py" = [
166166
"B",
@@ -197,10 +197,10 @@ lint.pycodestyle.max-line-length = 120
197197
lint.pydocstyle.convention = "pep257"
198198
lint.pyupgrade.keep-runtime-typing = false
199199

200-
[tool.pylint.main]
200+
[tool.pylint]
201201
# Maximum number of characters on a single line.
202-
max-line-length = 120
203-
disable = [
202+
main.max-line-length = 120
203+
main.disable = [
204204
"abstract-method",
205205
"arguments-differ",
206206
"arguments-renamed",
@@ -380,39 +380,39 @@ norecursedirs = [
380380
]
381381
strict = true
382382
filterwarnings = [
383-
'error',
384-
'default:Using or importing the ABCs:DeprecationWarning:unittest2.*',
383+
"error",
384+
"default:Using or importing the ABCs:DeprecationWarning:unittest2.*",
385385
# produced by older pyparsing<=2.2.0.
386-
'default:Using or importing the ABCs:DeprecationWarning:pyparsing.*',
387-
'default:the imp module is deprecated in favour of importlib:DeprecationWarning:nose.*',
386+
"default:Using or importing the ABCs:DeprecationWarning:pyparsing.*",
387+
"default:the imp module is deprecated in favour of importlib:DeprecationWarning:nose.*",
388388
# distutils is deprecated in 3.10, scheduled for removal in 3.12
389-
'ignore:The distutils package is deprecated:DeprecationWarning',
389+
"ignore:The distutils package is deprecated:DeprecationWarning",
390390
# produced by pytest-xdist
391-
'ignore:.*type argument to addoption.*:DeprecationWarning',
391+
"ignore:.*type argument to addoption.*:DeprecationWarning",
392392
# produced on execnet (pytest-xdist)
393-
'ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning',
393+
"ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning",
394394
# pytest's own futurewarnings
395-
'ignore::pytest.PytestExperimentalApiWarning',
395+
"ignore::pytest.PytestExperimentalApiWarning",
396396
# Do not cause SyntaxError for invalid escape sequences in py37.
397397
# Those are caught/handled by pyupgrade, and not easy to filter with the
398398
# module being the filename (with .py removed).
399-
'default:invalid escape sequence:DeprecationWarning',
399+
"default:invalid escape sequence:DeprecationWarning",
400400
# ignore not yet fixed warnings for hook markers
401-
'default:.*not marked using pytest.hook.*',
402-
'ignore:.*not marked using pytest.hook.*::xdist.*',
401+
"default:.*not marked using pytest.hook.*",
402+
"ignore:.*not marked using pytest.hook.*::xdist.*",
403403
# ignore use of unregistered marks, because we use many to test the implementation
404-
'ignore::_pytest.warning_types.PytestUnknownMarkWarning',
404+
"ignore::_pytest.warning_types.PytestUnknownMarkWarning",
405405
# https://github.com/benjaminp/six/issues/341
406-
'ignore:_SixMetaPathImporter\.exec_module\(\) not found; falling back to load_module\(\):ImportWarning',
406+
"ignore:_SixMetaPathImporter\\.exec_module\\(\\) not found; falling back to load_module\\(\\):ImportWarning",
407407
# https://github.com/benjaminp/six/pull/352
408-
'ignore:_SixMetaPathImporter\.find_spec\(\) not found; falling back to find_module\(\):ImportWarning',
408+
"ignore:_SixMetaPathImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning",
409409
# https://github.com/pypa/setuptools/pull/2517
410-
'ignore:VendorImporter\.find_spec\(\) not found; falling back to find_module\(\):ImportWarning',
410+
"ignore:VendorImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning",
411411
# https://github.com/pytest-dev/execnet/pull/127
412-
'ignore:isSet\(\) is deprecated, use is_set\(\) instead:DeprecationWarning',
412+
"ignore:isSet\\(\\) is deprecated, use is_set\\(\\) instead:DeprecationWarning",
413413
# https://github.com/pytest-dev/pytest/issues/2366
414414
# https://github.com/pytest-dev/pytest/pull/13057
415-
'default::pytest.PytestFDWarning',
415+
"default::pytest.PytestFDWarning",
416416
]
417417
pytester_example_dir = "testing/example_scripts"
418418
markers = [
@@ -432,47 +432,43 @@ markers = [
432432
"keep_ci_var",
433433
]
434434

435-
[tool.coverage.paths]
436-
source = [
437-
'src/',
438-
'*/lib/python*/site-packages/',
439-
'*/pypy*/site-packages/',
440-
'*\Lib\site-packages\',
441-
]
442-
443-
[tool.coverage.report]
444-
skip_covered = true
445-
show_missing = true
446-
exclude_lines = [
447-
'\#\s*pragma: no cover',
448-
'^\s*raise NotImplementedError\b',
449-
'^\s*return NotImplemented\b',
450-
'^\s*assert False(,|$)',
451-
'^\s*case unreachable:',
452-
'^\s*assert_never\(',
453-
'^\s*if TYPE_CHECKING:',
454-
'^\s*@overload( |$)',
455-
'^\s*def .+: \.\.\.$',
456-
'^\s*@pytest\.mark\.xfail',
457-
]
458-
459-
[tool.coverage.run]
460-
include = [
461-
'src/*',
462-
'testing/*',
463-
'*/lib/python*/site-packages/_pytest/*',
464-
'*/lib/python*/site-packages/pytest.py',
465-
'*/pypy*/site-packages/_pytest/*',
466-
'*/pypy*/site-packages/pytest.py',
467-
'*\Lib\site-packages\_pytest\*',
468-
'*\Lib\site-packages\pytest.py',
469-
]
470-
parallel = true
471-
branch = true
472-
patch = [ "subprocess" ]
435+
[tool.coverage]
436+
run.branch = true
473437
# The sysmon core (default since Python 3.14) is much slower.
474438
# Perhaps: https://github.com/coveragepy/coveragepy/issues/2082
475-
core = "ctrace"
439+
run.core = "ctrace"
440+
run.include = [
441+
"*/lib/python*/site-packages/_pytest/*",
442+
"*/lib/python*/site-packages/pytest.py",
443+
"*/pypy*/site-packages/_pytest/*",
444+
"*/pypy*/site-packages/pytest.py",
445+
"*\\Lib\\site-packages\\_pytest\\*",
446+
"*\\Lib\\site-packages\\pytest.py",
447+
"src/*",
448+
"testing/*",
449+
]
450+
run.parallel = true
451+
run.patch = [ "subprocess" ]
452+
paths.source = [
453+
"src/",
454+
"*/lib/python*/site-packages/",
455+
"*/pypy*/site-packages/",
456+
"*\\Lib\\site-packages\\",
457+
]
458+
report.exclude_lines = [
459+
"\\#\\s*pragma: no cover",
460+
"^\\s*@overload( |$)",
461+
"^\\s*@pytest\\.mark\\.xfail",
462+
"^\\s*assert False(,|$)",
463+
"^\\s*assert_never\\(",
464+
"^\\s*case unreachable:",
465+
"^\\s*def .+: \\.\\.\\.$",
466+
"^\\s*if TYPE_CHECKING:",
467+
"^\\s*raise NotImplementedError\\b",
468+
"^\\s*return NotImplemented\\b",
469+
]
470+
report.show_missing = true
471+
report.skip_covered = true
476472

477473
[tool.towncrier]
478474
package = "pytest"
@@ -481,76 +477,37 @@ filename = "doc/en/changelog.rst"
481477
directory = "changelog/"
482478
title_format = "pytest {version} ({project_date})"
483479
template = "changelog/_template.rst"
484-
485-
# NOTE: The types are declared because:
486-
# NOTE: - there is no mechanism to override just the value of
487-
# NOTE: `tool.towncrier.type.misc.showcontent`;
488-
# NOTE: - and, we want to declare extra non-default types for
489-
# NOTE: clarity and flexibility.
490-
491-
[[tool.towncrier.type]]
492-
# When something public gets removed in a breaking way. Could be
493-
# deprecated in an earlier release.
494-
directory = "breaking"
495-
name = "Removals and backward incompatible breaking changes"
496-
showcontent = true
497-
498-
[[tool.towncrier.type]]
499-
# Declarations of future API removals and breaking changes in behavior.
500-
directory = "deprecation"
501-
name = "Deprecations (removal in next major release)"
502-
showcontent = true
503-
504-
[[tool.towncrier.type]]
505-
# New behaviors, public APIs. That sort of stuff.
506-
directory = "feature"
507-
name = "New features"
508-
showcontent = true
509-
510-
[[tool.towncrier.type]]
511-
# New behaviors in existing features.
512-
directory = "improvement"
513-
name = "Improvements in existing functionality"
514-
showcontent = true
515-
516-
[[tool.towncrier.type]]
517-
# Something we deemed an improper undesired behavior that got corrected
518-
# in the release to match pre-agreed expectations.
519-
directory = "bugfix"
520-
name = "Bug fixes"
521-
showcontent = true
522-
523-
[[tool.towncrier.type]]
524-
# Updates regarding bundling dependencies.
525-
directory = "vendor"
526-
name = "Vendored libraries"
527-
showcontent = true
528-
529-
[[tool.towncrier.type]]
530-
# Notable updates to the documentation structure or build process.
531-
directory = "doc"
532-
name = "Improved documentation"
533-
showcontent = true
534-
535-
[[tool.towncrier.type]]
536-
# Notes for downstreams about unobvious side effects and tooling. Changes
537-
# in the test invocation considerations and runtime assumptions.
538-
directory = "packaging"
539-
name = "Packaging updates and notes for downstreams"
540-
showcontent = true
541-
542-
[[tool.towncrier.type]]
543-
# Stuff that affects the contributor experience. e.g. Running tests,
544-
# building the docs, setting up the development environment.
545-
directory = "contrib"
546-
name = "Contributor-facing changes"
547-
showcontent = true
548-
549-
[[tool.towncrier.type]]
550-
# Changes that are hard to assign to any of the above categories.
551-
directory = "misc"
552-
name = "Miscellaneous internal changes"
553-
showcontent = true
480+
type = [
481+
# NOTE: The types are declared because:
482+
# NOTE: - there is no mechanism to override just the value of
483+
# NOTE: `tool.towncrier.type.misc.showcontent`;
484+
# NOTE: - and, we want to declare extra non-default types for
485+
# NOTE: clarity and flexibility.
486+
# When something public gets removed in a breaking way. Could be
487+
# deprecated in an earlier release.
488+
{ directory = "breaking", name = "Removals and backward incompatible breaking changes", showcontent = true },
489+
# Declarations of future API removals and breaking changes in behavior.
490+
{ directory = "deprecation", name = "Deprecations (removal in next major release)", showcontent = true },
491+
# New behaviors, public APIs. That sort of stuff.
492+
{ directory = "feature", name = "New features", showcontent = true },
493+
# New behaviors in existing features.
494+
{ directory = "improvement", name = "Improvements in existing functionality", showcontent = true },
495+
# Something we deemed an improper undesired behavior that got corrected
496+
# in the release to match pre-agreed expectations.
497+
{ directory = "bugfix", name = "Bug fixes", showcontent = true },
498+
# Updates regarding bundling dependencies.
499+
{ directory = "vendor", name = "Vendored libraries", showcontent = true },
500+
# Notable updates to the documentation structure or build process.
501+
{ directory = "doc", name = "Improved documentation", showcontent = true },
502+
# Notes for downstreams about unobvious side effects and tooling. Changes
503+
# in the test invocation considerations and runtime assumptions.
504+
{ directory = "packaging", name = "Packaging updates and notes for downstreams", showcontent = true },
505+
# Stuff that affects the contributor experience. e.g. Running tests,
506+
# building the docs, setting up the development environment.
507+
{ directory = "contrib", name = "Contributor-facing changes", showcontent = true },
508+
# Changes that are hard to assign to any of the above categories.
509+
{ directory = "misc", name = "Miscellaneous internal changes", showcontent = true },
510+
]
554511

555512
[tool.mypy]
556513
files = [

src/_pytest/config/findpaths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def is_option(x: str) -> bool:
233233
return x.startswith("-")
234234

235235
def get_file_part_from_node_id(x: str) -> str:
236-
return x.split("::")[0]
236+
return x.split("::", maxsplit=1)[0]
237237

238238
def get_dir_from_path(path: Path) -> Path:
239239
if path.is_dir():

src/_pytest/terminal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def hasopt(self, char: str) -> bool:
476476
return char in self.reportchars
477477

478478
def write_fspath_result(self, nodeid: str, res: str, **markup: bool) -> None:
479-
fspath = self.config.rootpath / nodeid.split("::")[0]
479+
fspath = self.config.rootpath / nodeid.split("::", maxsplit=1)[0]
480480
if self.currentfspath is None or fspath != self.currentfspath:
481481
if self.currentfspath is not None and self._show_progress_info:
482482
self._write_progress_information_filling_space()
@@ -1034,7 +1034,9 @@ def mkrel(nodeid: str) -> str:
10341034
# fspath comes from testid which has a "/"-normalized path.
10351035
if fspath:
10361036
res = mkrel(nodeid)
1037-
if self.verbosity >= 2 and nodeid.split("::")[0] != nodes.norm_sep(fspath):
1037+
if self.verbosity >= 2 and nodeid.split("::", maxsplit=1)[
1038+
0
1039+
] != nodes.norm_sep(fspath):
10381040
res += " <- " + bestrelpath(self.startpath, Path(fspath))
10391041
else:
10401042
res = "[location]"

0 commit comments

Comments
 (0)