diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index d0cb07b22..addb2ad13 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -342,6 +342,12 @@ else: return f +# TODO: sealed classes are not supported yet +# https://github.com/mypyc/mypyc/issues/846 +def sealed(f: _T) -> _T: + return f + + if sys.version_info >= (3, 8): from functools import cached_property as cached_property else: diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index c32ce80cc..1b11f0106 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -6,6 +6,7 @@ from typing import TypeVar import attr from _pytest.compat import final +from _pytest.compat import sealed class PytestWarning(UserWarning): @@ -48,14 +49,15 @@ class PytestDeprecationWarning(PytestWarning, DeprecationWarning): __module__ = "pytest" -@final +@sealed class PytestRemovedIn8Warning(PytestDeprecationWarning): """Warning class for features that will be removed in pytest 8.""" __module__ = "pytest" -class PytestReturnNotNoneWarning(PytestDeprecationWarning): +@sealed +class PytestReturnNotNoneWarning(PytestRemovedIn8Warning): """Warning emitted when a test function is returning value other than None.""" __module__ = "pytest"