[ruff] Fix all consider [*cats, garfield] instead of cats + [garfield]
This commit is contained in:
parent
8967c527ff
commit
233ab89f13
|
@ -158,7 +158,6 @@ ignore = [
|
||||||
"D404", # First word of the docstring should not be "This"
|
"D404", # First word of the docstring should not be "This"
|
||||||
"D415", # First line should end with a period, question mark, or exclamation point
|
"D415", # First line should end with a period, question mark, or exclamation point
|
||||||
# ruff ignore
|
# ruff ignore
|
||||||
"RUF005", # Consider `(x, *y)` instead of concatenation
|
|
||||||
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
|
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ def pre_release(
|
||||||
|
|
||||||
def changelog(version: str, write_out: bool = False) -> None:
|
def changelog(version: str, write_out: bool = False) -> None:
|
||||||
addopts = [] if write_out else ["--draft"]
|
addopts = [] if write_out else ["--draft"]
|
||||||
check_call(["towncrier", "--yes", "--version", version] + addopts)
|
check_call(["towncrier", "--yes", "--version", version, *addopts])
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
|
|
@ -925,7 +925,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||||
# If any hooks implement assert_pass hook
|
# If any hooks implement assert_pass hook
|
||||||
hook_impl_test = ast.If(
|
hook_impl_test = ast.If(
|
||||||
self.helper("_check_if_assertion_pass_impl"),
|
self.helper("_check_if_assertion_pass_impl"),
|
||||||
self.expl_stmts + [hook_call_pass],
|
[*self.expl_stmts, hook_call_pass],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
statements_pass = [hook_impl_test]
|
statements_pass = [hook_impl_test]
|
||||||
|
|
|
@ -92,7 +92,8 @@ def _truncate_explanation(
|
||||||
else:
|
else:
|
||||||
# Add proper ellipsis when we were able to fit a full line exactly
|
# Add proper ellipsis when we were able to fit a full line exactly
|
||||||
truncated_explanation[-1] = "..."
|
truncated_explanation[-1] = "..."
|
||||||
return truncated_explanation + [
|
return [
|
||||||
|
*truncated_explanation,
|
||||||
"",
|
"",
|
||||||
f"...Full output truncated ({truncated_line_count} line"
|
f"...Full output truncated ({truncated_line_count} line"
|
||||||
f"{'' if truncated_line_count == 1 else 's'} hidden), {USAGE_MSG}",
|
f"{'' if truncated_line_count == 1 else 's'} hidden), {USAGE_MSG}",
|
||||||
|
|
|
@ -233,8 +233,8 @@ def assertrepr_compare(
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if explanation[0] != "":
|
if explanation[0] != "":
|
||||||
explanation = [""] + explanation
|
explanation = ["", *explanation]
|
||||||
return [summary] + explanation
|
return [summary, *explanation]
|
||||||
|
|
||||||
|
|
||||||
def _compare_eq_any(
|
def _compare_eq_any(
|
||||||
|
|
|
@ -238,7 +238,8 @@ essential_plugins = (
|
||||||
"helpconfig", # Provides -p.
|
"helpconfig", # Provides -p.
|
||||||
)
|
)
|
||||||
|
|
||||||
default_plugins = essential_plugins + (
|
default_plugins = (
|
||||||
|
*essential_plugins,
|
||||||
"python",
|
"python",
|
||||||
"terminal",
|
"terminal",
|
||||||
"debugging",
|
"debugging",
|
||||||
|
|
|
@ -122,7 +122,7 @@ class Parser:
|
||||||
from _pytest._argcomplete import filescompleter
|
from _pytest._argcomplete import filescompleter
|
||||||
|
|
||||||
optparser = MyOptionParser(self, self.extra_info, prog=self.prog)
|
optparser = MyOptionParser(self, self.extra_info, prog=self.prog)
|
||||||
groups = self._groups + [self._anonymous]
|
groups = [*self._groups, self._anonymous]
|
||||||
for group in groups:
|
for group in groups:
|
||||||
if group.options:
|
if group.options:
|
||||||
desc = group.description or group.name
|
desc = group.description or group.name
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ class Pytester:
|
||||||
:param cmdlineargs: Any extra command line arguments to use.
|
:param cmdlineargs: Any extra command line arguments to use.
|
||||||
"""
|
"""
|
||||||
p = self.makepyfile(source)
|
p = self.makepyfile(source)
|
||||||
values = list(cmdlineargs) + [p]
|
values = [*list(cmdlineargs), p]
|
||||||
return self.inline_run(*values)
|
return self.inline_run(*values)
|
||||||
|
|
||||||
def inline_genitems(self, *args) -> Tuple[List[Item], HookRecorder]:
|
def inline_genitems(self, *args) -> Tuple[List[Item], HookRecorder]:
|
||||||
|
@ -1491,10 +1491,10 @@ class Pytester:
|
||||||
"""
|
"""
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
p = make_numbered_dir(root=self.path, prefix="runpytest-", mode=0o700)
|
p = make_numbered_dir(root=self.path, prefix="runpytest-", mode=0o700)
|
||||||
args = ("--basetemp=%s" % p,) + args
|
args = ("--basetemp=%s" % p, *args)
|
||||||
plugins = [x for x in self.plugins if isinstance(x, str)]
|
plugins = [x for x in self.plugins if isinstance(x, str)]
|
||||||
if plugins:
|
if plugins:
|
||||||
args = ("-p", plugins[0]) + args
|
args = ("-p", plugins[0], *args)
|
||||||
args = self._getpytestargs() + args
|
args = self._getpytestargs() + args
|
||||||
return self.run(*args, timeout=timeout)
|
return self.run(*args, timeout=timeout)
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ def deprecated_call(
|
||||||
"""
|
"""
|
||||||
__tracebackhide__ = True
|
__tracebackhide__ = True
|
||||||
if func is not None:
|
if func is not None:
|
||||||
args = (func,) + args
|
args = (func, *args)
|
||||||
return warns(
|
return warns(
|
||||||
(DeprecationWarning, PendingDeprecationWarning, FutureWarning), *args, **kwargs
|
(DeprecationWarning, PendingDeprecationWarning, FutureWarning), *args, **kwargs
|
||||||
)
|
)
|
||||||
|
|
|
@ -1739,7 +1739,7 @@ def test_hidden_entries_of_chained_exceptions_are_not_shown(pytester: Pytester)
|
||||||
def add_note(err: BaseException, msg: str) -> None:
|
def add_note(err: BaseException, msg: str) -> None:
|
||||||
"""Adds a note to an exception inplace."""
|
"""Adds a note to an exception inplace."""
|
||||||
if sys.version_info < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
err.__notes__ = getattr(err, "__notes__", []) + [msg] # type: ignore[attr-defined]
|
err.__notes__ = [*getattr(err, "__notes__", []), msg] # type: ignore[attr-defined]
|
||||||
else:
|
else:
|
||||||
err.add_note(msg)
|
err.add_note(msg)
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,5 @@ if __name__ == "__main__":
|
||||||
for x in pytest.freeze_includes():
|
for x in pytest.freeze_includes():
|
||||||
hidden.extend(["--hidden-import", x])
|
hidden.extend(["--hidden-import", x])
|
||||||
hidden.extend(["--hidden-import", "distutils"])
|
hidden.extend(["--hidden-import", "distutils"])
|
||||||
args = ["pyinstaller", "--noconfirm"] + hidden + ["runtests_script.py"]
|
args = ["pyinstaller", "--noconfirm", *hidden, "runtests_script.py"]
|
||||||
subprocess.check_call(" ".join(args), shell=True)
|
subprocess.check_call(" ".join(args), shell=True)
|
||||||
|
|
|
@ -4536,5 +4536,5 @@ def test_yield_fixture_with_no_value(pytester: Pytester) -> None:
|
||||||
def test_deduplicate_names() -> None:
|
def test_deduplicate_names() -> None:
|
||||||
items = deduplicate_names("abacd")
|
items = deduplicate_names("abacd")
|
||||||
assert items == ("a", "b", "c", "d")
|
assert items == ("a", "b", "c", "d")
|
||||||
items = deduplicate_names(items + ("g", "f", "g", "e", "b"))
|
items = deduplicate_names((*items, "g", "f", "g", "e", "b"))
|
||||||
assert items == ("a", "b", "c", "d", "g", "f", "e")
|
assert items == ("a", "b", "c", "d", "g", "f", "e")
|
||||||
|
|
|
@ -42,7 +42,7 @@ class RunAndParse:
|
||||||
self, *args: Union[str, "os.PathLike[str]"], family: Optional[str] = "xunit1"
|
self, *args: Union[str, "os.PathLike[str]"], family: Optional[str] = "xunit1"
|
||||||
) -> Tuple[RunResult, "DomNode"]:
|
) -> Tuple[RunResult, "DomNode"]:
|
||||||
if family:
|
if family:
|
||||||
args = ("-o", "junit_family=" + family) + args
|
args = ("-o", "junit_family=" + family, *args)
|
||||||
xml_path = self.pytester.path.joinpath("junit.xml")
|
xml_path = self.pytester.path.joinpath("junit.xml")
|
||||||
result = self.pytester.runpytest("--junitxml=%s" % xml_path, *args)
|
result = self.pytester.runpytest("--junitxml=%s" % xml_path, *args)
|
||||||
if family == "xunit2":
|
if family == "xunit2":
|
||||||
|
|
|
@ -417,8 +417,8 @@ class TestTerminal:
|
||||||
|
|
||||||
result = pytester.runpytest("-v")
|
result = pytester.runpytest("-v")
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
common_output
|
[
|
||||||
+ [
|
*common_output,
|
||||||
"test_verbose_skip_reason.py::test_long_skip SKIPPED (1 cannot *...) *",
|
"test_verbose_skip_reason.py::test_long_skip SKIPPED (1 cannot *...) *",
|
||||||
"test_verbose_skip_reason.py::test_long_xfail XFAIL (2 cannot *...) *",
|
"test_verbose_skip_reason.py::test_long_xfail XFAIL (2 cannot *...) *",
|
||||||
]
|
]
|
||||||
|
@ -426,17 +426,13 @@ class TestTerminal:
|
||||||
|
|
||||||
result = pytester.runpytest("-vv")
|
result = pytester.runpytest("-vv")
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
common_output
|
[
|
||||||
+ [
|
*common_output,
|
||||||
(
|
"test_verbose_skip_reason.py::test_long_skip SKIPPED"
|
||||||
"test_verbose_skip_reason.py::test_long_skip SKIPPED"
|
" (1 cannot do foobar",
|
||||||
" (1 cannot do foobar"
|
|
||||||
),
|
|
||||||
"because baz is missing due to I don't know what) *",
|
"because baz is missing due to I don't know what) *",
|
||||||
(
|
"test_verbose_skip_reason.py::test_long_xfail XFAIL"
|
||||||
"test_verbose_skip_reason.py::test_long_xfail XFAIL"
|
" (2 cannot do foobar",
|
||||||
" (2 cannot do foobar"
|
|
||||||
),
|
|
||||||
"because baz is missing due to I don't know what) *",
|
"because baz is missing due to I don't know what) *",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue