[DONTMERGE] refactor: clean up node constructors — move logic to from_parent by RonnyPfannschmidt · Pull Request #14227 · pytest-dev/pytest
and others added 6 commits
February 22, 2026 20:01… Item.from_parent The _check_item_and_collector_diamond_inheritance validation is not data storage — it's a one-time class-level check. Moving it to from_parent keeps __init__ focused on storing values. Also converts the method to a classmethod since it only inspects the class, not the instance. Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude <claude@anthropic.com>
…m_parent Package.__init__ only did `session = parent.session` which FSCollector already handles. Removing the __init__ entirely and adding an explicit from_parent with a typed signature for clarity. Also removes the now-unused LEGACY_PATH import from python.py. Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude <claude@anthropic.com>
…smethods and from_parent Extracts _derive_name and _derive_nodeid as classmethods on FSCollector. The from_parent method now pre-computes name and nodeid before calling super, so __init__ receives fully resolved values in the normal path. The __init__ retains fallback derivation for backward compatibility with non-cooperative constructors (plugins using positional args). Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude <claude@anthropic.com>
…to from_parent DoctestItem.__init__ now only stores runner, dtest, and obj. The fixture resolution (getfixtureinfo) and _initrequest() are moved to from_parent, which is the only production entry point for creating DoctestItem instances. Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude <claude@anthropic.com>
…nit__ to from_parent Function.__init__ now only stores _obj, _instance, originalname, and callspec. The marker extension, keyword updates, fixture resolution (getfixtureinfo), and _initrequest() are extracted into a new _setup_markers_and_fixtures method called from from_parent after construction. This keeps __init__ focused on storing values while from_parent handles all post-construction initialization logic. Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude <claude@anthropic.com>
1. FSCollector: fix double _imply_path call that would produce duplicate deprecation warnings when fspath is used. Now __init__ skips the _imply_path call when path is already resolved (by from_parent), using _check_path for consistency validation instead. 2. Function: remove dead keywords/fixtureinfo parameters from __init__ since from_parent now pops them before calling super. Replace with **kw for forward-compatibility with additional kwargs. Co-authored-by: Cursor AI <ai@cursor.sh> Co-authored-by: Anthropic Claude <claude@anthropic.com>
Copilot AI review requested due to automatic review settings
February 23, 2026 09:52
RonnyPfannschmidt
changed the title
refactor: clean up node constructors — move logic to from_parent
[DONTMERGE] refactor: clean up node constructors — move logic to from_parent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters