Skip to content

Annotate FixtureRequest.node as Any and document why - #15227

Open
RonnyPfannschmidt wants to merge 2 commits into
mainfrom
claude/project-thread-4etye4
Open

RonnyPfannschmidt wants to merge 2 commits into
mainfrom
claude/project-thread-4etye4

Conversation

@RonnyPfannschmidt

@RonnyPfannschmidt RonnyPfannschmidt commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Requested by Ronny · project thread

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

FixtureRequest.node is deliberately not typed as Node. See bluetech's reasoning in #13888 (comment). Several PRs have tried to add that annotation (#15103, #15226), and it would break typed user code such as request.node.function or request.node.rep_call under mypy.

This PR:

  • adds a source comment above FixtureRequest.node that explains the decision and links the reasoning;
  • annotates the return as an explicit -> Any. Strict pyright reports an unannotated return as Unknown (reportUnknownMemberType on every request.node access). An explicit Any fixes that, and mypy treats both forms the same. Suggested by Contrabang in review.

Verified: pyright strict on request.node.nodeid / .function goes from 6 errors to 0, and mypy --strict stays clean.

Refs #13888.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FbVKGSuPZFfJpPHTPANBQa

Refs #13888.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FbVKGSuPZFfJpPHTPANBQa
@RonnyPfannschmidt RonnyPfannschmidt added the skip news used on prs to opt out of the changelog requirement label Oct 20, 2026 — with Claude
@RonnyPfannschmidt RonnyPfannschmidt self-assigned this Oct 20, 2026
Comment thread src/_pytest/fixtures.py Outdated
Strict pyright reports an unannotated return as Unknown, so spell out
the intended Any. Refs #13888.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FbVKGSuPZFfJpPHTPANBQa
@RonnyPfannschmidt RonnyPfannschmidt changed the title Document why FixtureRequest.node is not type-annotated Annotate FixtureRequest.node as Any and document why Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants