Skip to content

Commit dd515e0

Browse files
pre-commit again
1 parent aec6cb6 commit dd515e0

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

changelog/5975.deprecation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Deprecate using direct constructors for ``Nodes``.
33
Instead they are new constructed via ``Node.from_parent``.
44

55
This painful transitional mechanism enables us to detangle the very intensely
6-
entangled ``Node`` relationships.
6+
entangled ``Node`` relationships.

src/_pytest/deprecated.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
All constants defined in this module should be either PytestWarning instances or UnformattedWarning
99
in case of warnings which need to format their messages.
1010
"""
11-
from _pytest.warning_types import PytestDeprecationWarning, UnformattedWarning
11+
from _pytest.warning_types import PytestDeprecationWarning
12+
from _pytest.warning_types import UnformattedWarning
1213

1314
# set of plugins which have been integrated into the core; we use this list to ignore
1415
# them during registration to avoid conflicts
@@ -35,5 +36,7 @@
3536
"as a keyword argument instead."
3637
)
3738

38-
NODE_USE_FROM_PARENT = UnformattedWarning(PytestDeprecationWarning,
39-
"direct construction of {name} has been deprecated, please use {name}.from_parent",)
39+
NODE_USE_FROM_PARENT = UnformattedWarning(
40+
PytestDeprecationWarning,
41+
"direct construction of {name} has been deprecated, please use {name}.from_parent",
42+
)

src/_pytest/doctest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ def collect(self):
336336
parser = doctest.DocTestParser()
337337
test = parser.get_doctest(text, globs, name, filename, 0)
338338
if test.examples:
339-
yield DoctestItem.from_parent(self, name=test.name, runner=runner, dtest=test)
339+
yield DoctestItem.from_parent(
340+
self, name=test.name, runner=runner, dtest=test
341+
)
340342

341343

342344
def _check_all_skipped(test):
@@ -432,7 +434,9 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
432434

433435
for test in finder.find(module, module.__name__):
434436
if test.examples: # skip empty doctests
435-
yield DoctestItem.from_parent(self, name=test.name, runner=runner, dtest=test)
437+
yield DoctestItem.from_parent(
438+
self, name=test.name, runner=runner, dtest=test
439+
)
436440

437441

438442
def _setup_fixtures(doctest_item):

src/_pytest/nodes.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import warnings
33
from contextlib import contextmanager
44
from functools import lru_cache
5-
from functools import wraps
65
from typing import Any
76
from typing import Dict
87
from typing import List
@@ -14,11 +13,11 @@
1413

1514
import _pytest._code
1615
from _pytest.compat import getfslineno
16+
from _pytest.deprecated import NODE_USE_FROM_PARENT
1717
from _pytest.mark.structures import Mark
1818
from _pytest.mark.structures import MarkDecorator
1919
from _pytest.mark.structures import NodeKeywords
2020
from _pytest.outcomes import fail
21-
from _pytest.deprecated import NODE_USE_FROM_PARENT
2221

2322
if False: # TYPE_CHECKING
2423
# Imported here due to circular import.
@@ -72,10 +71,7 @@ class NodeMeta(type):
7271

7372
def __call__(self, *k, **kw):
7473
if not self.__in_named_ctor:
75-
warnings.warn(
76-
NODE_USE_FROM_PARENT.format(name=self.__name__),
77-
stacklevel=3,
78-
)
74+
warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=3)
7975
return self._create(*k, **kw)
8076

8177
@contextmanager

0 commit comments

Comments
 (0)