Mark some public and to-be-public classes as @final

This indicates at least for people using type checkers that these
classes are not designed for inheritance and we make no stability
guarantees regarding inheritance of them.

Currently this doesn't show up in the docs. Sphinx does actually support
`@final`, however it only works when imported directly from `typing`,
while we import from `_pytest.compat`.

In the future there might also be a `@sealed` decorator which would
cover some more cases.
This commit is contained in:
Ran Benita
2020-09-21 17:45:24 +03:00
parent cdfdb3a25d
commit a99ca879e7
23 changed files with 81 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ from typing import TypeVar
from typing import Union
import _pytest._code
from _pytest.compat import final
from _pytest.compat import overload
from _pytest.compat import STRING_TYPES
from _pytest.compat import TYPE_CHECKING
@@ -699,6 +700,7 @@ def raises( # noqa: F811
raises.Exception = fail.Exception # type: ignore
@final
class RaisesContext(Generic[_E]):
def __init__(
self,