Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 21, 2024
1 parent adf39a9 commit de3a747
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/_pytest/_io/saferepr.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def repr(self, x: object) -> str:
if self.use_ascii:
s = ascii(x)
else:

s = super().repr(x)
except (KeyboardInterrupt, SystemExit):
raise
Expand Down
24 changes: 6 additions & 18 deletions src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,9 +1018,7 @@ def visit_BoolOp(self, boolop: ast.BoolOp) -> tuple[ast.Name, str]:
]
):
pytest_temp = self.variable()
self.variables_overwrite[self.scope][
v.left.target.id
] = v.left # type:ignore[assignment]
self.variables_overwrite[self.scope][v.left.target.id] = v.left # type:ignore[assignment]
v.left.target.id = pytest_temp
self.push_format_context()
res, expl = self.visit(v)
Expand Down Expand Up @@ -1064,19 +1062,15 @@ def visit_Call(self, call: ast.Call) -> tuple[ast.Name, str]:
if isinstance(arg, ast.Name) and arg.id in self.variables_overwrite.get(
self.scope, {}
):
arg = self.variables_overwrite[self.scope][
arg.id
] # type:ignore[assignment]
arg = self.variables_overwrite[self.scope][arg.id] # type:ignore[assignment]
res, expl = self.visit(arg)
arg_expls.append(expl)
new_args.append(res)
for keyword in call.keywords:
if isinstance(
keyword.value, ast.Name
) and keyword.value.id in self.variables_overwrite.get(self.scope, {}):
keyword.value = self.variables_overwrite[self.scope][
keyword.value.id
] # type:ignore[assignment]
keyword.value = self.variables_overwrite[self.scope][keyword.value.id] # type:ignore[assignment]
res, expl = self.visit(keyword.value)
new_kwargs.append(ast.keyword(keyword.arg, res))
if keyword.arg:
Expand Down Expand Up @@ -1113,13 +1107,9 @@ def visit_Compare(self, comp: ast.Compare) -> tuple[ast.expr, str]:
if isinstance(
comp.left, ast.Name
) and comp.left.id in self.variables_overwrite.get(self.scope, {}):
comp.left = self.variables_overwrite[self.scope][
comp.left.id
] # type:ignore[assignment]
comp.left = self.variables_overwrite[self.scope][comp.left.id] # type:ignore[assignment]
if isinstance(comp.left, ast.NamedExpr):
self.variables_overwrite[self.scope][
comp.left.target.id
] = comp.left # type:ignore[assignment]
self.variables_overwrite[self.scope][comp.left.target.id] = comp.left # type:ignore[assignment]
left_res, left_expl = self.visit(comp.left)
if isinstance(comp.left, (ast.Compare, ast.BoolOp)):
left_expl = f"({left_expl})"
Expand All @@ -1137,9 +1127,7 @@ def visit_Compare(self, comp: ast.Compare) -> tuple[ast.expr, str]:
and next_operand.target.id == left_res.id
):
next_operand.target.id = self.variable()
self.variables_overwrite[self.scope][
left_res.id
] = next_operand # type:ignore[assignment]
self.variables_overwrite[self.scope][left_res.id] = next_operand # type:ignore[assignment]
next_res, next_expl = self.visit(next_operand)
if isinstance(next_operand, (ast.Compare, ast.BoolOp)):
next_expl = f"({next_expl})"
Expand Down
2 changes: 0 additions & 2 deletions testing/test_assertrewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from typing import Mapping
from unittest import mock
import zipfile
import re

import _pytest._code
from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
Expand All @@ -36,7 +35,6 @@
from _pytest.config import ExitCode
from _pytest.pathlib import make_numbered_dir
from _pytest.pytester import Pytester
from _pytest.assertion.rewrite import _saferepr
import pytest


Expand Down

0 comments on commit de3a747

Please sign in to comment.