Skip to content

[7.0] Change Node.reportinfo() return value from py.path to str|os.PathLike[str] #9184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2021

Conversation

bluetech
Copy link
Member

@bluetech bluetech commented Oct 9, 2021

Refs #7259. Should only be merged for the 7.0 (i.e. after 6.3.x is branched).

reportinfo() is the last remaining py.path-only code path in pytest,
i.e. the last piece holding back py.path deprecation. The problem with
it is that plugins/users use it from both sides -- implementing it
(returning the value) and using it (using the return value). Dealing
with implementers is easy enough -- allow to return os.PathLike[str].
But for callers who expect strictly py.path this will break and
there's not really a good way to provide backward compat for this.

From analyzing a corpus of 680 pytest plugins, the vast majority of
reportinfo appearances are implementations, and the few callers don't
actually access the path part of the return tuple.

As for test suites that might access reportinfo (e.g. using
request.node.reportinfo() or other ways), that is much harder to
survey, but from the ones I searched, I only found case
(pytest_teamcity, but even then it uses str(fspath) so is unlikely
to be affected in practice). They are better served with using
node.location or node.path directly.

Therefore, just break it and change the return type to
str|os.PathLike[str].

…hLike[str]`

`reportinfo()` is the last remaining py.path-only code path in pytest,
i.e. the last piece holding back py.path deprecation. The problem with
it is that plugins/users use it from both sides -- implementing it
(returning the value) and using it (using the return value). Dealing
with implementers is easy enough -- allow to return `os.PathLike[str]`.
But for callers who expect strictly `py.path` this will break and
there's not really a good way to provide backward compat for this.

From analyzing a corpus of 680 pytest plugins, the vast majority of
`reportinfo` appearances are implementations, and the few callers don't
actually access the path part of the return tuple.

As for test suites that might access `reportinfo` (e.g. using
`request.node.reportinfo()` or other ways), that is much harder to
survey, but from the ones I searched, I only found case
(`pytest_teamcity`, but even then it uses `str(fspath)` so is unlikely
to be affected in practice). They are better served with using
`node.location` or `node.path` directly.

Therefore, just break it and change the return type to
`str|os.PathLike[str]`.

Refs pytest-dev#7259.
@bluetech bluetech force-pushed the reportinfo-pathlike branch from 1584e24 to 7eee5c1 Compare October 9, 2021 12:02
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable, thanks for doing the research and going ahead with this! 👍

Refs #7259. Should only be merged for the 7.0 (i.e. after 6.3.x is branched).

I think we don't plan to have 6.3.X releases in the future, we will go straight for 7.0 for the next major release: main is in a state where a 6.3.X would not be possible anyway, as it already contains breaking changes.

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, thanks!

@bluetech
Copy link
Member Author

I think we don't plan to have 6.3.X releases in the future, we will go straight for 7.0 for the next major release: main is in a state where a 6.3.X would not be possible anyway, as it already contains breaking changes.

Oh good to know. So according to the plan set out in #7259, we should merge this now.

@bluetech bluetech merged commit da3b301 into pytest-dev:main Oct 11, 2021
@bluetech bluetech deleted the reportinfo-pathlike branch October 11, 2021 18:58
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.

None yet

3 participants