Skip to content

Commit 1bb125a

Browse files
committed
Fix RUF052
1 parent ee26a54 commit 1bb125a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/ansiblelint/loaders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def load_ignore_txt(filepath: Path | None = None) -> dict[str, set[IgnoreRule]]:
8484
ignore_file = IGNORE_FILE.alternative
8585

8686
if ignore_file:
87-
with open(ignore_file, encoding="utf-8") as _ignore_file:
87+
with open(ignore_file, encoding="utf-8") as ignore_file_h:
8888
_logger.debug("Loading ignores from '%s'", ignore_file)
89-
for line in _ignore_file:
89+
for line in ignore_file_h:
9090
entry = line.split("#")[0].rstrip()
9191
if entry:
9292
try:

test/test_loaders.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def test_load_ignore_txt_default_success() -> None:
3535
with tempfile.TemporaryDirectory() as temporary_directory:
3636
ignore_file = Path(temporary_directory) / IGNORE_FILE.default
3737

38-
with ignore_file.open("w", encoding="utf-8") as _ignore_file:
39-
_ignore_file.write(
38+
with ignore_file.open("w", encoding="utf-8") as ignore_file_h:
39+
ignore_file_h.write(
4040
dedent(
4141
"""
4242
# See https://docs.ansible.com/projects/lint/configuring/#ignoring-rules-for-entire-files
@@ -70,8 +70,8 @@ def test_load_ignore_txt_default_success_alternative() -> None:
7070
ignore_file = Path(temporary_directory) / IGNORE_FILE.alternative
7171
ignore_file.parent.mkdir(parents=True)
7272

73-
with ignore_file.open("w", encoding="utf-8") as _ignore_file:
74-
_ignore_file.write(
73+
with ignore_file.open("w", encoding="utf-8") as ignore_file_h:
74+
ignore_file_h.write(
7575
dedent(
7676
"""
7777
playbook.yml foo-bar
@@ -104,8 +104,8 @@ def test_load_ignore_txt_custom_success() -> None:
104104
ignore_file = Path(temporary_directory) / "subdir" / "my_ignores.txt"
105105
ignore_file.parent.mkdir(parents=True, exist_ok=True)
106106

107-
with ignore_file.open("w", encoding="utf-8") as _ignore_file:
108-
_ignore_file.write(
107+
with ignore_file.open("w", encoding="utf-8") as ignore_file_h:
108+
ignore_file_h.write(
109109
dedent(
110110
"""
111111
playbook.yml hector
@@ -144,8 +144,8 @@ def test_load_ignore_txt_invalid_tags(monkeypatch: pytest.MonkeyPatch) -> None:
144144
with tempfile.TemporaryDirectory() as temporary_directory:
145145
ignore_file = Path(temporary_directory) / IGNORE_FILE.default
146146

147-
with ignore_file.open("w", encoding="utf-8") as _ignore_file:
148-
_ignore_file.write(
147+
with ignore_file.open("w", encoding="utf-8") as ignore_file_h:
148+
ignore_file_h.write(
149149
dedent(
150150
"""
151151
playbook2.yml package-latest invalid-tag

0 commit comments

Comments
 (0)