Skip to content

Commit 779cecd

Browse files
committed
Comply with new lint rule for unused variables
1 parent aaeb1ca commit 779cecd

34 files changed

+111
-108
lines changed

doc/en/example/.ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ignore = ["RUF059"]

src/_pytest/_code/source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def getstatementrange(self, lineno: int) -> tuple[int, int]:
103103
which containing the given lineno."""
104104
if not (0 <= lineno < len(self)):
105105
raise IndexError("lineno out of range")
106-
ast, start, end = getstatementrange_ast(lineno, self)
106+
_ast, start, end = getstatementrange_ast(lineno, self)
107107
return start, end
108108

109109
def deindent(self) -> Source:

src/_pytest/_py/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def new(self, **kw):
652652
if not kw:
653653
obj.strpath = self.strpath
654654
return obj
655-
drive, dirname, basename, purebasename, ext = self._getbyspec(
655+
drive, dirname, _basename, purebasename, ext = self._getbyspec(
656656
"drive,dirname,basename,purebasename,ext"
657657
)
658658
if "basename" in kw:

src/_pytest/config/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ def pytest_load_initial_conftests(self, early_config: Config) -> None:
12171217
# early_config.args it not set yet. But we need it for
12181218
# discovering the initial conftests. So "pre-run" the logic here.
12191219
# It will be done for real in `parse()`.
1220-
args, args_source = early_config._decide_args(
1220+
args, _args_source = early_config._decide_args(
12211221
args=early_config.known_args_namespace.file_or_dir,
12221222
pyargs=early_config.known_args_namespace.pyargs,
12231223
testpaths=early_config.getini("testpaths"),
@@ -1273,7 +1273,7 @@ def _consider_importhook(self, args: Sequence[str]) -> None:
12731273
and find all the installed plugins to mark them for rewriting
12741274
by the importhook.
12751275
"""
1276-
ns, unknown_args = self._parser.parse_known_and_unknown_args(args)
1276+
ns, _unknown_args = self._parser.parse_known_and_unknown_args(args)
12771277
mode = getattr(ns, "assertmode", "plain")
12781278

12791279
disable_autoload = getattr(ns, "disable_plugin_autoload", False) or bool(
@@ -1630,7 +1630,7 @@ def _getini_unknown_type(self, name: str, type: str, value: object):
16301630

16311631
def _getini(self, name: str):
16321632
try:
1633-
description, type, default = self._parser._inidict[name]
1633+
_description, type, default = self._parser._inidict[name]
16341634
except KeyError as e:
16351635
raise ValueError(f"unknown configuration value: {name!r}") from e
16361636
override_value = self._get_override_ini_value(name)

src/_pytest/helpconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def showhelp(config: Config) -> None:
185185
indent_len = 24 # based on argparse's max_help_position=24
186186
indent = " " * indent_len
187187
for name in config._parser._ininames:
188-
help, type, default = config._parser._inidict[name]
188+
help, type, _default = config._parser._inidict[name]
189189
if type is None:
190190
type = "string"
191191
if help is None:

src/_pytest/mark/structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_empty_parameterset_mark(
6060

6161
argslisting = ", ".join(argnames)
6262

63-
fs, lineno = getfslineno(func)
63+
_fs, lineno = getfslineno(func)
6464
reason = f"got empty parameter set for ({argslisting})"
6565
requested_mark = config.getini(EMPTY_PARAMETERSET_OPTION)
6666
if requested_mark in ("", None, "skip"):

src/_pytest/reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def head_line(self) -> str | None:
188188
even in patch releases.
189189
"""
190190
if self.location is not None:
191-
fspath, lineno, domain = self.location
191+
_fspath, _lineno, domain = self.location
192192
return domain
193193
return None
194194

testing/_py/test_local.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
from unittest import mock
1010
import warnings
1111

12-
from py import error
1312
from py.path import local
1413

14+
from py import error
15+
1516
import pytest
1617

1718

testing/acceptance_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,18 +644,17 @@ def test_invoke_with_invalid_type(self) -> None:
644644
):
645645
pytest.main("-h") # type: ignore[arg-type]
646646

647-
def test_invoke_with_path(self, pytester: Pytester, capsys) -> None:
647+
def test_invoke_with_path(self, pytester: Pytester) -> None:
648648
retcode = pytest.main([str(pytester.path)])
649649
assert retcode == ExitCode.NO_TESTS_COLLECTED
650-
out, err = capsys.readouterr()
651650

652651
def test_invoke_plugin_api(self, capsys) -> None:
653652
class MyPlugin:
654653
def pytest_addoption(self, parser):
655654
parser.addoption("--myopt")
656655

657656
pytest.main(["-h"], plugins=[MyPlugin()])
658-
out, err = capsys.readouterr()
657+
out, _err = capsys.readouterr()
659658
assert "--myopt" in out
660659

661660
def test_pyargs_importerror(self, pytester: Pytester, monkeypatch) -> None:

testing/code/test_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def test_unicode_handling() -> None:
8686
value = "ąć".encode()
8787

8888
def f() -> None:
89-
raise Exception(value)
89+
raise ValueError(value)
9090

91-
excinfo = pytest.raises(Exception, f)
91+
excinfo = pytest.raises(ValueError, f)
9292
str(excinfo)
9393

9494

0 commit comments

Comments
 (0)