Skip to content

Add return type annotation to FixtureRequest.node - #15226

Closed
Thibault-dlr wants to merge 1 commit into
pytest-dev:mainfrom
Thibault-dlr:main
Closed

Thibault-dlr wants to merge 1 commit into
pytest-dev:mainfrom
Thibault-dlr:main

Conversation

@Thibault-dlr

Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Member

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

Thanks for the PR, but I'm closing it. request.node is left untyped on purpose. See bluetech's reasoning in #13888 (comment): a declared Node (or Item | Collector) return type would force users to assert isinstance(...) or cast whenever they know the concrete type, which is the common case.

With this change, mypy --strict on user code like request.node.callspec, request.node.function or request.node.rep_call (the documented pattern for making test reports available in fixtures) fails with "Node" has no attribute .... All of those pass on main.

It also duplicates the earlier #15103, which proposes the same change.

A follow-up PR will add a comment in the source that explains this, so the question doesn't keep coming back.


Generated by Claude Code

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants