pytest
pytest copied to clipboard
FixtureRequest.node should be typed to return a Node
Currently the property node of FixtureRequest is defined as
@property
@abc.abstractmethod
def node(self):
"""Underlying collection node (depends on current request scope)."""
raise NotImplementedError()
which implicitly types the return type as Any. However, based on the name of the function and the underlying implementations it should return a nodes.Node.
Unfortunately, when I tried this on a fork, I got the following error:
mypy............................................................................Failed
- hook id: mypy
- exit code: 1
src/_pytest/junitxml.py:294: error: "Node" has no attribute "user_properties" [attr-defined]
Found 1 error in 1 file (checked 239 source files)
This happens because junitxml actually expects to receive a nodes.NodeItem instead of a plain nodes.Node.
One quick fix for this would be to put a type assertion in junitxml, but I'm not sure if that's the preferred approach. I'd be happy to send a PR if someone could give ve some guidance on how to best resolve this.