[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
b035a7b4f1
commit
edbe8f1a06
|
@ -278,9 +278,9 @@ class TracebackEntry:
|
|||
|
||||
Mostly for internal use.
|
||||
"""
|
||||
tbh: Union[
|
||||
bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]
|
||||
] = False
|
||||
tbh: Union[bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]] = (
|
||||
False
|
||||
)
|
||||
for maybe_ns_dct in (self.frame.f_locals, self.frame.f_globals):
|
||||
# in normal cases, f_locals and f_globals are dictionaries
|
||||
# however via `exec(...)` / `eval(...)` they can be other types
|
||||
|
@ -377,12 +377,10 @@ class Traceback(List[TracebackEntry]):
|
|||
return self
|
||||
|
||||
@overload
|
||||
def __getitem__(self, key: "SupportsIndex") -> TracebackEntry:
|
||||
...
|
||||
def __getitem__(self, key: "SupportsIndex") -> TracebackEntry: ...
|
||||
|
||||
@overload
|
||||
def __getitem__(self, key: slice) -> "Traceback":
|
||||
...
|
||||
def __getitem__(self, key: slice) -> "Traceback": ...
|
||||
|
||||
def __getitem__(
|
||||
self, key: Union["SupportsIndex", slice]
|
||||
|
@ -1045,15 +1043,15 @@ class FormattedExcinfo:
|
|||
# full support for exception groups added to ExceptionInfo.
|
||||
# See https://github.com/pytest-dev/pytest/issues/9159
|
||||
if isinstance(e, BaseExceptionGroup):
|
||||
reprtraceback: Union[
|
||||
ReprTracebackNative, ReprTraceback
|
||||
] = ReprTracebackNative(
|
||||
reprtraceback: Union[ReprTracebackNative, ReprTraceback] = (
|
||||
ReprTracebackNative(
|
||||
traceback.format_exception(
|
||||
type(excinfo_.value),
|
||||
excinfo_.value,
|
||||
excinfo_.traceback[0]._rawentry,
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
reprtraceback = self.repr_traceback(excinfo_)
|
||||
reprcrash = excinfo_._getreprcrash()
|
||||
|
|
|
@ -47,12 +47,10 @@ class Source:
|
|||
__hash__ = None # type: ignore
|
||||
|
||||
@overload
|
||||
def __getitem__(self, key: int) -> str:
|
||||
...
|
||||
def __getitem__(self, key: int) -> str: ...
|
||||
|
||||
@overload
|
||||
def __getitem__(self, key: slice) -> "Source":
|
||||
...
|
||||
def __getitem__(self, key: slice) -> "Source": ...
|
||||
|
||||
def __getitem__(self, key: Union[int, slice]) -> Union[str, "Source"]:
|
||||
if isinstance(key, int):
|
||||
|
|
|
@ -204,12 +204,10 @@ class Stat:
|
|||
if TYPE_CHECKING:
|
||||
|
||||
@property
|
||||
def size(self) -> int:
|
||||
...
|
||||
def size(self) -> int: ...
|
||||
|
||||
@property
|
||||
def mtime(self) -> float:
|
||||
...
|
||||
def mtime(self) -> float: ...
|
||||
|
||||
def __getattr__(self, name: str) -> Any:
|
||||
return getattr(self._osstatresult, "st_" + name)
|
||||
|
@ -962,12 +960,10 @@ class LocalPath:
|
|||
return p
|
||||
|
||||
@overload
|
||||
def stat(self, raising: Literal[True] = ...) -> Stat:
|
||||
...
|
||||
def stat(self, raising: Literal[True] = ...) -> Stat: ...
|
||||
|
||||
@overload
|
||||
def stat(self, raising: Literal[False]) -> Stat | None:
|
||||
...
|
||||
def stat(self, raising: Literal[False]) -> Stat | None: ...
|
||||
|
||||
def stat(self, raising: bool = True) -> Stat | None:
|
||||
"""Return an os.stat() tuple."""
|
||||
|
|
|
@ -669,9 +669,9 @@ class AssertionRewriter(ast.NodeVisitor):
|
|||
self.enable_assertion_pass_hook = False
|
||||
self.source = source
|
||||
self.scope: tuple[ast.AST, ...] = ()
|
||||
self.variables_overwrite: defaultdict[
|
||||
tuple[ast.AST, ...], Dict[str, str]
|
||||
] = defaultdict(dict)
|
||||
self.variables_overwrite: defaultdict[tuple[ast.AST, ...], Dict[str, str]] = (
|
||||
defaultdict(dict)
|
||||
)
|
||||
|
||||
def run(self, mod: ast.Module) -> None:
|
||||
"""Find all assert statements in *mod* and rewrite them."""
|
||||
|
|
|
@ -1231,8 +1231,7 @@ def fixture(
|
|||
Union[Sequence[Optional[object]], Callable[[Any], Optional[object]]]
|
||||
] = ...,
|
||||
name: Optional[str] = ...,
|
||||
) -> FixtureFunction:
|
||||
...
|
||||
) -> FixtureFunction: ...
|
||||
|
||||
|
||||
@overload
|
||||
|
@ -1246,8 +1245,7 @@ def fixture( # noqa: F811
|
|||
Union[Sequence[Optional[object]], Callable[[Any], Optional[object]]]
|
||||
] = ...,
|
||||
name: Optional[str] = None,
|
||||
) -> FixtureFunctionMarker:
|
||||
...
|
||||
) -> FixtureFunctionMarker: ...
|
||||
|
||||
|
||||
def fixture( # noqa: F811
|
||||
|
|
|
@ -721,14 +721,12 @@ class Session(nodes.Collector):
|
|||
@overload
|
||||
def perform_collect(
|
||||
self, args: Optional[Sequence[str]] = ..., genitems: "Literal[True]" = ...
|
||||
) -> Sequence[nodes.Item]:
|
||||
...
|
||||
) -> Sequence[nodes.Item]: ...
|
||||
|
||||
@overload
|
||||
def perform_collect( # noqa: F811
|
||||
self, args: Optional[Sequence[str]] = ..., genitems: bool = ...
|
||||
) -> Sequence[Union[nodes.Item, nodes.Collector]]:
|
||||
...
|
||||
) -> Sequence[Union[nodes.Item, nodes.Collector]]: ...
|
||||
|
||||
def perform_collect( # noqa: F811
|
||||
self, args: Optional[Sequence[str]] = None, genitems: bool = True
|
||||
|
|
|
@ -434,12 +434,10 @@ if TYPE_CHECKING:
|
|||
|
||||
class _SkipMarkDecorator(MarkDecorator):
|
||||
@overload # type: ignore[override,misc,no-overload-impl]
|
||||
def __call__(self, arg: Markable) -> Markable:
|
||||
...
|
||||
def __call__(self, arg: Markable) -> Markable: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, reason: str = ...) -> "MarkDecorator":
|
||||
...
|
||||
def __call__(self, reason: str = ...) -> "MarkDecorator": ...
|
||||
|
||||
class _SkipifMarkDecorator(MarkDecorator):
|
||||
def __call__( # type: ignore[override]
|
||||
|
@ -447,13 +445,11 @@ if TYPE_CHECKING:
|
|||
condition: Union[str, bool] = ...,
|
||||
*conditions: Union[str, bool],
|
||||
reason: str = ...,
|
||||
) -> MarkDecorator:
|
||||
...
|
||||
) -> MarkDecorator: ...
|
||||
|
||||
class _XfailMarkDecorator(MarkDecorator):
|
||||
@overload # type: ignore[override,misc,no-overload-impl]
|
||||
def __call__(self, arg: Markable) -> Markable:
|
||||
...
|
||||
def __call__(self, arg: Markable) -> Markable: ...
|
||||
|
||||
@overload
|
||||
def __call__(
|
||||
|
@ -466,8 +462,7 @@ if TYPE_CHECKING:
|
|||
None, Type[BaseException], Tuple[Type[BaseException], ...]
|
||||
] = ...,
|
||||
strict: bool = ...,
|
||||
) -> MarkDecorator:
|
||||
...
|
||||
) -> MarkDecorator: ...
|
||||
|
||||
class _ParametrizeMarkDecorator(MarkDecorator):
|
||||
def __call__( # type: ignore[override]
|
||||
|
@ -483,8 +478,7 @@ if TYPE_CHECKING:
|
|||
]
|
||||
] = ...,
|
||||
scope: Optional[_ScopeName] = ...,
|
||||
) -> MarkDecorator:
|
||||
...
|
||||
) -> MarkDecorator: ...
|
||||
|
||||
class _UsefixturesMarkDecorator(MarkDecorator):
|
||||
def __call__(self, *fixtures: str) -> MarkDecorator: # type: ignore[override]
|
||||
|
|
|
@ -169,8 +169,7 @@ class MonkeyPatch:
|
|||
name: object,
|
||||
value: Notset = ...,
|
||||
raising: bool = ...,
|
||||
) -> None:
|
||||
...
|
||||
) -> None: ...
|
||||
|
||||
@overload
|
||||
def setattr(
|
||||
|
@ -179,8 +178,7 @@ class MonkeyPatch:
|
|||
name: str,
|
||||
value: object,
|
||||
raising: bool = ...,
|
||||
) -> None:
|
||||
...
|
||||
) -> None: ...
|
||||
|
||||
def setattr(
|
||||
self,
|
||||
|
|
|
@ -104,6 +104,7 @@ class Node(abc.ABC, metaclass=NodeMeta):
|
|||
``Collector``\'s are the internal nodes of the tree, and ``Item``\'s are the
|
||||
leaf nodes.
|
||||
"""
|
||||
|
||||
# Use __slots__ to make attribute access faster.
|
||||
# Note that __dict__ is still available.
|
||||
__slots__ = (
|
||||
|
@ -325,12 +326,10 @@ class Node(abc.ABC, metaclass=NodeMeta):
|
|||
yield node, mark
|
||||
|
||||
@overload
|
||||
def get_closest_marker(self, name: str) -> Optional[Mark]:
|
||||
...
|
||||
def get_closest_marker(self, name: str) -> Optional[Mark]: ...
|
||||
|
||||
@overload
|
||||
def get_closest_marker(self, name: str, default: Mark) -> Mark:
|
||||
...
|
||||
def get_closest_marker(self, name: str, default: Mark) -> Mark: ...
|
||||
|
||||
def get_closest_marker(
|
||||
self, name: str, default: Optional[Mark] = None
|
||||
|
|
|
@ -244,8 +244,7 @@ class RecordedHookCall:
|
|||
|
||||
if TYPE_CHECKING:
|
||||
# The class has undetermined attributes, this tells mypy about it.
|
||||
def __getattr__(self, key: str):
|
||||
...
|
||||
def __getattr__(self, key: str): ...
|
||||
|
||||
|
||||
@final
|
||||
|
@ -326,15 +325,13 @@ class HookRecorder:
|
|||
def getreports(
|
||||
self,
|
||||
names: "Literal['pytest_collectreport']",
|
||||
) -> Sequence[CollectReport]:
|
||||
...
|
||||
) -> Sequence[CollectReport]: ...
|
||||
|
||||
@overload
|
||||
def getreports(
|
||||
self,
|
||||
names: "Literal['pytest_runtest_logreport']",
|
||||
) -> Sequence[TestReport]:
|
||||
...
|
||||
) -> Sequence[TestReport]: ...
|
||||
|
||||
@overload
|
||||
def getreports(
|
||||
|
@ -343,8 +340,7 @@ class HookRecorder:
|
|||
"pytest_collectreport",
|
||||
"pytest_runtest_logreport",
|
||||
),
|
||||
) -> Sequence[Union[CollectReport, TestReport]]:
|
||||
...
|
||||
) -> Sequence[Union[CollectReport, TestReport]]: ...
|
||||
|
||||
def getreports(
|
||||
self,
|
||||
|
@ -391,15 +387,13 @@ class HookRecorder:
|
|||
def getfailures(
|
||||
self,
|
||||
names: "Literal['pytest_collectreport']",
|
||||
) -> Sequence[CollectReport]:
|
||||
...
|
||||
) -> Sequence[CollectReport]: ...
|
||||
|
||||
@overload
|
||||
def getfailures(
|
||||
self,
|
||||
names: "Literal['pytest_runtest_logreport']",
|
||||
) -> Sequence[TestReport]:
|
||||
...
|
||||
) -> Sequence[TestReport]: ...
|
||||
|
||||
@overload
|
||||
def getfailures(
|
||||
|
@ -408,8 +402,7 @@ class HookRecorder:
|
|||
"pytest_collectreport",
|
||||
"pytest_runtest_logreport",
|
||||
),
|
||||
) -> Sequence[Union[CollectReport, TestReport]]:
|
||||
...
|
||||
) -> Sequence[Union[CollectReport, TestReport]]: ...
|
||||
|
||||
def getfailures(
|
||||
self,
|
||||
|
|
|
@ -1793,9 +1793,11 @@ class Function(PyobjMixin, nodes.Item):
|
|||
if self.config.getoption("tbstyle", "auto") == "auto":
|
||||
if len(ntraceback) > 2:
|
||||
ntraceback = Traceback(
|
||||
(
|
||||
entry
|
||||
if i == 0 or i == len(ntraceback) - 1
|
||||
else entry.with_repr_style("short")
|
||||
)
|
||||
for i, entry in enumerate(ntraceback)
|
||||
)
|
||||
|
||||
|
|
|
@ -779,8 +779,7 @@ def raises(
|
|||
expected_exception: Union[Type[E], Tuple[Type[E], ...]],
|
||||
*,
|
||||
match: Optional[Union[str, Pattern[str]]] = ...,
|
||||
) -> "RaisesContext[E]":
|
||||
...
|
||||
) -> "RaisesContext[E]": ...
|
||||
|
||||
|
||||
@overload
|
||||
|
@ -789,8 +788,7 @@ def raises( # noqa: F811
|
|||
func: Callable[..., Any],
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
) -> _pytest._code.ExceptionInfo[E]:
|
||||
...
|
||||
) -> _pytest._code.ExceptionInfo[E]: ...
|
||||
|
||||
|
||||
def raises( # noqa: F811
|
||||
|
|
|
@ -42,15 +42,13 @@ def recwarn() -> Generator["WarningsRecorder", None, None]:
|
|||
@overload
|
||||
def deprecated_call(
|
||||
*, match: Optional[Union[str, Pattern[str]]] = ...
|
||||
) -> "WarningsRecorder":
|
||||
...
|
||||
) -> "WarningsRecorder": ...
|
||||
|
||||
|
||||
@overload
|
||||
def deprecated_call( # noqa: F811
|
||||
func: Callable[..., T], *args: Any, **kwargs: Any
|
||||
) -> T:
|
||||
...
|
||||
) -> T: ...
|
||||
|
||||
|
||||
def deprecated_call( # noqa: F811
|
||||
|
@ -92,8 +90,7 @@ def warns(
|
|||
expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = ...,
|
||||
*,
|
||||
match: Optional[Union[str, Pattern[str]]] = ...,
|
||||
) -> "WarningsChecker":
|
||||
...
|
||||
) -> "WarningsChecker": ...
|
||||
|
||||
|
||||
@overload
|
||||
|
@ -102,8 +99,7 @@ def warns( # noqa: F811
|
|||
func: Callable[..., T],
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
) -> T:
|
||||
...
|
||||
) -> T: ...
|
||||
|
||||
|
||||
def warns( # noqa: F811
|
||||
|
|
|
@ -71,8 +71,7 @@ class BaseReport:
|
|||
|
||||
if TYPE_CHECKING:
|
||||
# Can have arbitrary fields given to __init__().
|
||||
def __getattr__(self, key: str) -> Any:
|
||||
...
|
||||
def __getattr__(self, key: str) -> Any: ...
|
||||
|
||||
def toterminal(self, out: TerminalWriter) -> None:
|
||||
if hasattr(self, "node"):
|
||||
|
@ -609,9 +608,9 @@ def _report_kwargs_from_json(reportdict: Dict[str, Any]) -> Dict[str, Any]:
|
|||
description,
|
||||
)
|
||||
)
|
||||
exception_info: Union[
|
||||
ExceptionChainRepr, ReprExceptionInfo
|
||||
] = ExceptionChainRepr(chain)
|
||||
exception_info: Union[ExceptionChainRepr, ReprExceptionInfo] = (
|
||||
ExceptionChainRepr(chain)
|
||||
)
|
||||
else:
|
||||
exception_info = ReprExceptionInfo(
|
||||
reprtraceback=reprtraceback,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Generate an executable with pytest runner embedded using PyInstaller."""
|
||||
|
||||
if __name__ == "__main__":
|
||||
import pytest
|
||||
import subprocess
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Called by tox.ini: uses the generated executable to run the tests in ./tests/
|
||||
directory.
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -2109,9 +2109,9 @@ class TestPytestPluginsVariable:
|
|||
args = ("--pyargs", "pkg") if use_pyargs else ()
|
||||
res = pytester.runpytest(*args)
|
||||
assert res.ret == (0 if use_pyargs else 2)
|
||||
msg = (
|
||||
msg
|
||||
) = "Defining 'pytest_plugins' in a non-top-level conftest is no longer supported"
|
||||
msg = msg = (
|
||||
"Defining 'pytest_plugins' in a non-top-level conftest is no longer supported"
|
||||
)
|
||||
if use_pyargs:
|
||||
assert msg not in res.stdout.str()
|
||||
else:
|
||||
|
|
|
@ -296,9 +296,9 @@ class TestReportSerialization:
|
|||
|
||||
reprec = pytester.inline_run()
|
||||
if report_class is TestReport:
|
||||
reports: Union[
|
||||
Sequence[TestReport], Sequence[CollectReport]
|
||||
] = reprec.getreports("pytest_runtest_logreport")
|
||||
reports: Union[Sequence[TestReport], Sequence[CollectReport]] = (
|
||||
reprec.getreports("pytest_runtest_logreport")
|
||||
)
|
||||
# we have 3 reports: setup/call/teardown
|
||||
assert len(reports) == 3
|
||||
# get the call report
|
||||
|
|
Loading…
Reference in New Issue