Skip to content

Commit 375c424

Browse files
committed
tests: Update pre-commit hooks
- remove hacking noqa because hacking is no longer used - use dict.fromkeys simplified by ruff C420 rule Change-Id: I81cef79c29d3ef02c9b6c8eaed9bcb96feaac445
1 parent d47c9f1 commit 375c424

7 files changed

+15
-16
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858
- id: rst-inline-touching-normal
5959
- id: text-unicode-replacement-char
6060
- repo: https://github.com/astral-sh/ruff-pre-commit
61-
rev: v0.9.10
61+
rev: v0.11.2
6262
hooks:
6363
- id: ruff
6464
args:

pywikibot/family.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ def langs(cls):
844844
if hasattr(cls, 'code_aliases'):
845845
codes += cls.code_aliases
846846

847-
return {code: cls.domain for code in codes}
847+
return dict.fromkeys(codes, cls.domain)
848848

849849
def scriptpath(self, code):
850850
"""Return the script path for this family."""

scripts/data_ingestion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@
8888
8989
.. warning:: Put it in one line, otherwise it won't work correctly.
9090
91-
""" # noqa: E501 ,W505
91+
""" # noqa: E501,W505
9292
#
93-
# (C) Pywikibot team, 2012-2022
93+
# (C) Pywikibot team, 2012-2025
9494
#
9595
# Distributed under the terms of the MIT license.
9696
#

scripts/protect.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ def main(*args: str) -> None:
225225
protection_levels)
226226
# set the default value for all
227227
# None (not the string 'none') will be ignored by Site.protect()
228-
combined_protections = {p_type: default_level
229-
for p_type in protection_types}
228+
combined_protections = dict.fromkeys(protection_types, default_level)
230229
for p_type, level in protections.items():
231230
level = check_protection_level(p_type, level, protection_levels,
232231
default_level)

tests/family_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ def test_eq_family_with_string_repr_same_family(self):
7676
family = Family.load('wikipedia')
7777
other = 'wikipedia'
7878
self.assertEqual(family, other)
79-
self.assertFalse(family != other) # noqa: H204
79+
self.assertFalse(family != other)
8080

8181
def test_ne_family_with_string_repr_different_family(self):
8282
"""Test that Family and string with different name are not equal."""
8383
family = Family.load('wikipedia')
8484
other = 'wikisource'
8585
self.assertNotEqual(family, other)
86-
self.assertFalse(family == other) # noqa: H204
86+
self.assertFalse(family == other)
8787

8888
def test_eq_family_with_string_repr_not_existing_family(self):
8989
"""Test that Family and string with different name are not equal."""

tests/logentries_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""Test :mod:`logentries` module."""
33
#
4-
# (C) Pywikibot team, 2015-2024
4+
# (C) Pywikibot team, 2015-2025
55
#
66
# Distributed under the terms of the MIT license.
77
#
@@ -284,7 +284,7 @@ def test_equality(self):
284284
le4 = next(gen1)
285285
le5 = next(gen2)
286286
self.assertEqual(le1, le2)
287-
self.assertFalse(le1 != le2) # noqa: H204
287+
self.assertFalse(le1 != le2)
288288
self.assertNotEqual(le1, le3)
289289
self.assertNotEqual(le1, site)
290290
self.assertIsInstance(le4, OtherLogEntry)

tests/wbtypes_tests.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""Tests for the Wikidata parts of the page module."""
33
#
4-
# (C) Pywikibot team, 2008-2024
4+
# (C) Pywikibot team, 2008-2025
55
#
66
# Distributed under the terms of the MIT license.
77
#
@@ -510,11 +510,11 @@ def test_comparison_timezones_equal(self):
510510
self.assertGreaterEqual(t2, t1)
511511
self.assertNotEqual(t1, t2)
512512
self.assertNotEqual(t2, t1)
513-
# Ignore H205: We specifically want to test the operator
514-
self.assertFalse(t1 > t2) # noqa: H205
515-
self.assertFalse(t2 > t1) # noqa: H205
516-
self.assertFalse(t1 < t2) # noqa: H205
517-
self.assertFalse(t2 < t1) # noqa: H205
513+
# We specifically want to test the operator
514+
self.assertFalse(t1 > t2)
515+
self.assertFalse(t2 > t1)
516+
self.assertFalse(t1 < t2)
517+
self.assertFalse(t2 < t1)
518518

519519
def test_comparison_equal_instant(self):
520520
"""Test the equal_instant method."""

0 commit comments

Comments
 (0)