pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Reintroduce PytestReturnNotNoneWarning

Open nicoddemus opened this issue 6 months ago • 5 comments

Since this warning is meant to be permanent, added proper documentation to the assert section in the docs.

Fixes #13477

nicoddemus avatar Jun 07 '25 12:06 nicoddemus

Do we consider this a bugfix that is OK to enter in the next patch release, or should we wait for 8.5?

nicoddemus avatar Jun 07 '25 12:06 nicoddemus

We should backport as we correct a regression

RonnyPfannschmidt avatar Jun 07 '25 12:06 RonnyPfannschmidt

I'm getting the same failure on main locally.

Testing main on https://github.com/pytest-dev/pytest/pull/13496 to confirm the failure is unrelated to these changes.

nicoddemus avatar Jun 07 '25 15:06 nicoddemus

Blocked by https://github.com/pytest-dev/pytest/issues/13497, will wait for us to fix that before merging this.

nicoddemus avatar Jun 07 '25 16:06 nicoddemus

The related issue is possibly something larger to fix so id prefer we dont block on it

RonnyPfannschmidt avatar Jun 07 '25 17:06 RonnyPfannschmidt

Apologies if this comment is off the mark, but do we need to separately handle the await case (https://github.com/pytest-dev/pytest/issues/11372) that was the original rationale for changing the warning to an error?

If I understand correctly your question, no. The state of affairs will be:

  • async tests will always fail if not handled by a plugin.
  • Normal tests will always generate a warning if they return non-None.

nicoddemus avatar Jun 16 '25 20:06 nicoddemus

Backport to 8.4.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/8.4.x/53f05c44d9530c4ac5ce5804ef75fe61713d46d8/pr-13495

Backported as https://github.com/pytest-dev/pytest/pull/13527

🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.

patchback[bot] avatar Jun 16 '25 21:06 patchback[bot]