Remove _ prefix from TypeVars which appear in public API

The prefixes make the API Reference docs (for e.g. `pytest.raises`,
`pytest.fixture`) uglier.

Being under `_pytest` is sufficient from a privacy perspective, so let's
drop them.
This commit is contained in:
Ran Benita
2021-03-13 10:54:40 +02:00
parent 146eda93e7
commit 5bbfb4e058
3 changed files with 48 additions and 48 deletions

View File

@@ -436,26 +436,26 @@ co_equal = compile(
)
_E = TypeVar("_E", bound=BaseException, covariant=True)
E = TypeVar("E", bound=BaseException, covariant=True)
@final
@attr.s(repr=False)
class ExceptionInfo(Generic[_E]):
class ExceptionInfo(Generic[E]):
"""Wraps sys.exc_info() objects and offers help for navigating the traceback."""
_assert_start_repr = "AssertionError('assert "
_excinfo = attr.ib(type=Optional[Tuple[Type["_E"], "_E", TracebackType]])
_excinfo = attr.ib(type=Optional[Tuple[Type["E"], "E", TracebackType]])
_striptext = attr.ib(type=str, default="")
_traceback = attr.ib(type=Optional[Traceback], default=None)
@classmethod
def from_exc_info(
cls,
exc_info: Tuple[Type[_E], _E, TracebackType],
exc_info: Tuple[Type[E], E, TracebackType],
exprinfo: Optional[str] = None,
) -> "ExceptionInfo[_E]":
) -> "ExceptionInfo[E]":
"""Return an ExceptionInfo for an existing exc_info tuple.
.. warning::
@@ -500,17 +500,17 @@ class ExceptionInfo(Generic[_E]):
return ExceptionInfo.from_exc_info(exc_info, exprinfo)
@classmethod
def for_later(cls) -> "ExceptionInfo[_E]":
def for_later(cls) -> "ExceptionInfo[E]":
"""Return an unfilled ExceptionInfo."""
return cls(None)
def fill_unfilled(self, exc_info: Tuple[Type[_E], _E, TracebackType]) -> None:
def fill_unfilled(self, exc_info: Tuple[Type[E], E, TracebackType]) -> None:
"""Fill an unfilled ExceptionInfo created with ``for_later()``."""
assert self._excinfo is None, "ExceptionInfo was already filled"
self._excinfo = exc_info
@property
def type(self) -> Type[_E]:
def type(self) -> Type[E]:
"""The exception class."""
assert (
self._excinfo is not None
@@ -518,7 +518,7 @@ class ExceptionInfo(Generic[_E]):
return self._excinfo[0]
@property
def value(self) -> _E:
def value(self) -> E:
"""The exception value."""
assert (
self._excinfo is not None