Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #11885

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
args: [--safe, --quiet]
Expand Down
26 changes: 12 additions & 14 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@

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
Expand Down Expand Up @@ -377,12 +377,10 @@
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]
Expand Down Expand Up @@ -1045,13 +1043,13 @@
# 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(
traceback.format_exception(
type(excinfo_.value),
excinfo_.value,
excinfo_.traceback[0]._rawentry,
reprtraceback: Union[ReprTracebackNative, ReprTraceback] = (

Check warning on line 1046 in src/_pytest/_code/code.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/_code/code.py#L1046

Added line #L1046 was not covered by tests
ReprTracebackNative(
traceback.format_exception(
type(excinfo_.value),
excinfo_.value,
excinfo_.traceback[0]._rawentry,
)
)
)
else:
Expand Down
6 changes: 2 additions & 4 deletions src/_pytest/_code/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ def __eq__(self, other: object) -> bool:
__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):
Expand Down
12 changes: 4 additions & 8 deletions src/_pytest/_py/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -962,12 +960,10 @@ def ensure(self, *args, **kwargs):
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."""
Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,9 @@ def __init__(
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."""
Expand Down
6 changes: 2 additions & 4 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,7 @@ def fixture(
Union[Sequence[Optional[object]], Callable[[Any], Optional[object]]]
] = ...,
name: Optional[str] = ...,
) -> FixtureFunction:
...
) -> FixtureFunction: ...


@overload
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,12 @@ def _collect_path(
@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
Expand Down
18 changes: 6 additions & 12 deletions src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,26 +434,22 @@ def store_mark(obj, mark: Mark) -> None:

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]
self,
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__(
Expand All @@ -466,8 +462,7 @@ def __call__(
None, Type[BaseException], Tuple[Type[BaseException], ...]
] = ...,
strict: bool = ...,
) -> MarkDecorator:
...
) -> MarkDecorator: ...

class _ParametrizeMarkDecorator(MarkDecorator):
def __call__( # type: ignore[override]
Expand All @@ -483,8 +478,7 @@ def __call__( # type: ignore[override]
]
] = ...,
scope: Optional[_ScopeName] = ...,
) -> MarkDecorator:
...
) -> MarkDecorator: ...

class _UsefixturesMarkDecorator(MarkDecorator):
def __call__(self, *fixtures: str) -> MarkDecorator: # type: ignore[override]
Expand Down
6 changes: 2 additions & 4 deletions src/_pytest/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ def setattr(
name: object,
value: Notset = ...,
raising: bool = ...,
) -> None:
...
) -> None: ...

@overload
def setattr(
Expand All @@ -179,8 +178,7 @@ def setattr(
name: str,
value: object,
raising: bool = ...,
) -> None:
...
) -> None: ...

def setattr(
self,
Expand Down
7 changes: 3 additions & 4 deletions src/_pytest/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = (
Expand Down Expand Up @@ -325,12 +326,10 @@ def iter_markers_with_node(
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
Expand Down
21 changes: 7 additions & 14 deletions src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ def __repr__(self) -> str:

if TYPE_CHECKING:
# The class has undetermined attributes, this tells mypy about it.
def __getattr__(self, key: str):
...
def __getattr__(self, key: str): ...


@final
Expand Down Expand Up @@ -326,15 +325,13 @@ def getcall(self, name: str) -> RecordedHookCall:
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(
Expand All @@ -343,8 +340,7 @@ def getreports(
"pytest_collectreport",
"pytest_runtest_logreport",
),
) -> Sequence[Union[CollectReport, TestReport]]:
...
) -> Sequence[Union[CollectReport, TestReport]]: ...

def getreports(
self,
Expand Down Expand Up @@ -391,15 +387,13 @@ def matchreport(
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(
Expand All @@ -408,8 +402,7 @@ def getfailures(
"pytest_collectreport",
"pytest_runtest_logreport",
),
) -> Sequence[Union[CollectReport, TestReport]]:
...
) -> Sequence[Union[CollectReport, TestReport]]: ...

def getfailures(
self,
Expand Down
8 changes: 5 additions & 3 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,9 +1793,11 @@ def _traceback_filter(self, excinfo: ExceptionInfo[BaseException]) -> Traceback:
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")
(
entry
if i == 0 or i == len(ntraceback) - 1
else entry.with_repr_style("short")
)
for i, entry in enumerate(ntraceback)
)

Expand Down
6 changes: 2 additions & 4 deletions src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 4 additions & 8 deletions src/_pytest/recwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,8 +90,7 @@ def warns(
expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = ...,
*,
match: Optional[Union[str, Pattern[str]]] = ...,
) -> "WarningsChecker":
...
) -> "WarningsChecker": ...


@overload
Expand All @@ -102,8 +99,7 @@ def warns( # noqa: F811
func: Callable[..., T],
*args: Any,
**kwargs: Any,
) -> T:
...
) -> T: ...


def warns( # noqa: F811
Expand Down