Skip to content

Commit 4716589

Browse files
authored
DEV: Modify use of ignore Ruff rule ARG005 (#3215)
ARG005: Unused lambda argument. If there is a single unused lambda argument, replacing it with an underscore does not trigger the rule.
1 parent f805e6d commit 4716589

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

pypdf/_page_labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def get_label_from_nums(dictionary_object: DictionaryObject, index: int) -> str:
144144
break
145145
i += 2
146146
m = {
147-
None: lambda n: "",
147+
None: lambda _: "",
148148
"/D": lambda n: str(n),
149149
"/R": number2uppercase_roman_numeral,
150150
"/r": number2lowercase_roman_numeral,

pypdf/_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ def add_outline_item_destination(
18381838
self,
18391839
page_destination.inc_parent_counter_outline
18401840
if is_open
1841-
else (lambda x, y: 0),
1841+
else (lambda x, y: 0), # noqa: ARG005
18421842
)
18431843
if "/Count" not in page_destination:
18441844
page_destination[NameObject("/Count")] = NumberObject(0)

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ ignore = [
133133
"ARG001", # Unused function argument
134134
"ARG002", # Unused method argument
135135
"ARG004", # Unused static method argument
136-
"ARG005", # Unused lambda argument
137136
"B028", # No explicit `stacklevel` keyword argument found
138137
"B904", # Within an `except` clause, raise exceptions with
139138
"B905", # `zip()` without an explicit `strict=` parameter

tests/scripts/test_make_release.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_get_git_commits_since_tag():
4242
make_release = pytest.importorskip("make_release")
4343

4444
with open(COMMITS__VERSION_4_0_1, mode="rb") as commits, mock.patch(
45-
"urllib.request.urlopen", side_effect=lambda n: commits
45+
"urllib.request.urlopen", side_effect=lambda _: commits
4646
), mock.patch("subprocess.check_output", return_value=GIT_LOG__VERSION_4_0_1):
4747
commits = make_release.get_git_commits_since_tag("4.0.1")
4848
assert commits == [
@@ -88,7 +88,7 @@ def test_get_formatted_changes():
8888
make_release = pytest.importorskip("make_release")
8989

9090
with open(COMMITS__VERSION_4_0_1, mode="rb") as commits, mock.patch(
91-
"urllib.request.urlopen", side_effect=lambda n: commits
91+
"urllib.request.urlopen", side_effect=lambda _: commits
9292
), mock.patch("subprocess.check_output", return_value=GIT_LOG__VERSION_4_0_1):
9393
output, output_with_user = make_release.get_formatted_changes("4.0.1")
9494

tests/test_text_extraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
@pytest.mark.samples
25-
@pytest.mark.parametrize(("visitor_text"), [None, lambda a, b, c, d, e: None])
25+
@pytest.mark.parametrize(("visitor_text"), [None, lambda a, b, c, d, e: None]) # noqa: ARG005
2626
def test_multi_language(visitor_text):
2727
reader = PdfReader(RESOURCE_ROOT / "multilang.pdf")
2828
txt = reader.pages[0].extract_text(visitor_text=visitor_text)

0 commit comments

Comments
 (0)