Skip to content
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

PytestReturnNotNoneWarning now subclasses PytestRemovedIn8Warning #10196

Merged
merged 7 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ def final(f):
return f


# TODO: sealed classes are not supported yet
graingert marked this conversation as resolved.
Show resolved Hide resolved
# https://github.com/mypyc/mypyc/issues/846
def sealed(f: _T) -> _T:
graingert marked this conversation as resolved.
Show resolved Hide resolved
return f


if sys.version_info >= (3, 8):
from functools import cached_property as cached_property
else:
Expand Down
6 changes: 4 additions & 2 deletions src/_pytest/warning_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import attr

from _pytest.compat import final
from _pytest.compat import sealed
graingert marked this conversation as resolved.
Show resolved Hide resolved


class PytestWarning(UserWarning):
Expand Down Expand Up @@ -48,14 +49,15 @@ class PytestDeprecationWarning(PytestWarning, DeprecationWarning):
__module__ = "pytest"


@final
@sealed
graingert marked this conversation as resolved.
Show resolved Hide resolved
class PytestRemovedIn8Warning(PytestDeprecationWarning):
"""Warning class for features that will be removed in pytest 8."""

__module__ = "pytest"


class PytestReturnNotNoneWarning(PytestDeprecationWarning):
@sealed
graingert marked this conversation as resolved.
Show resolved Hide resolved
class PytestReturnNotNoneWarning(PytestRemovedIn8Warning):
Copy link
Member

@nicoddemus nicoddemus Oct 9, 2022

Choose a reason for hiding this comment

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

Sorry, I don't recall the original discussion, do we ever plan to make returning non-None an error? Do you have a link to the original discussion?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ahh thanks!

"""Warning emitted when a test function is returning value other than None."""

__module__ = "pytest"
Expand Down