From a980ac08dd02e2aca935902a679dd46d41de720a Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 8 Aug 2022 10:23:26 +0100 Subject: [PATCH] make PytestReturnNotNoneWarning a RemovedIn8Warning by removing the `@final` decorator --- src/_pytest/compat.py | 6 ++++++ src/_pytest/warning_types.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) 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"