Skip to content

Commit d2b2142

Browse files
Add class docstring to NodeMeta (#11427)
1 parent a38ad25 commit d2b2142

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/_pytest/nodes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ def _imply_path(
127127

128128

129129
class NodeMeta(type):
130+
"""Metaclass used by :class:`Node` to enforce that direct construction raises
131+
:class:`Failed`.
132+
133+
This behaviour supports the indirection introduced with :meth:`Node.from_parent`,
134+
the named constructor to be used instead of direct construction. The design
135+
decision to enforce indirection with :class:`NodeMeta` was made as a
136+
temporary aid for refactoring the collection tree, which was diagnosed to
137+
have :class:`Node` objects whose creational patterns were overly entangled.
138+
Once the refactoring is complete, this metaclass can be removed.
139+
140+
See https://github.com/pytest-dev/pytest/projects/3 for an overview of the
141+
progress on detangling the :class:`Node` classes.
142+
"""
143+
130144
def __call__(self, *k, **kw):
131145
msg = (
132146
"Direct construction of {name} has been deprecated, please use {name}.from_parent.\n"

0 commit comments

Comments
 (0)