jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1130578?usp=email )
Change subject: tests: Update pre-commit hooks ......................................................................
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 --- M .pre-commit-config.yaml M pywikibot/family.py M scripts/data_ingestion.py M scripts/protect.py M tests/family_tests.py M tests/logentries_tests.py M tests/wbtypes_tests.py 7 files changed, 15 insertions(+), 16 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 687971b..221d027 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ - id: rst-inline-touching-normal - id: text-unicode-replacement-char - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.10 + rev: v0.11.2 hooks: - id: ruff args: diff --git a/pywikibot/family.py b/pywikibot/family.py index 77e8da6..e04b48a 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -844,7 +844,7 @@ if hasattr(cls, 'code_aliases'): codes += cls.code_aliases
- return {code: cls.domain for code in codes} + return dict.fromkeys(codes, cls.domain)
def scriptpath(self, code): """Return the script path for this family.""" diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py index 97933af..275b1cd 100755 --- a/scripts/data_ingestion.py +++ b/scripts/data_ingestion.py @@ -88,9 +88,9 @@
.. warning:: Put it in one line, otherwise it won't work correctly.
-""" # noqa: E501 ,W505 +""" # noqa: E501,W505 # -# (C) Pywikibot team, 2012-2022 +# (C) Pywikibot team, 2012-2025 # # Distributed under the terms of the MIT license. # diff --git a/scripts/protect.py b/scripts/protect.py index 8150148..36bc1c5 100755 --- a/scripts/protect.py +++ b/scripts/protect.py @@ -225,8 +225,7 @@ protection_levels) # set the default value for all # None (not the string 'none') will be ignored by Site.protect() - combined_protections = {p_type: default_level - for p_type in protection_types} + combined_protections = dict.fromkeys(protection_types, default_level) for p_type, level in protections.items(): level = check_protection_level(p_type, level, protection_levels, default_level) diff --git a/tests/family_tests.py b/tests/family_tests.py index 3bfa9ac..7819913 100755 --- a/tests/family_tests.py +++ b/tests/family_tests.py @@ -76,14 +76,14 @@ family = Family.load('wikipedia') other = 'wikipedia' self.assertEqual(family, other) - self.assertFalse(family != other) # noqa: H204 + self.assertFalse(family != other)
def test_ne_family_with_string_repr_different_family(self): """Test that Family and string with different name are not equal.""" family = Family.load('wikipedia') other = 'wikisource' self.assertNotEqual(family, other) - self.assertFalse(family == other) # noqa: H204 + self.assertFalse(family == other)
def test_eq_family_with_string_repr_not_existing_family(self): """Test that Family and string with different name are not equal.""" diff --git a/tests/logentries_tests.py b/tests/logentries_tests.py index 1d74f6f..0094083 100755 --- a/tests/logentries_tests.py +++ b/tests/logentries_tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Test :mod:`logentries` module.""" # -# (C) Pywikibot team, 2015-2024 +# (C) Pywikibot team, 2015-2025 # # Distributed under the terms of the MIT license. # @@ -284,7 +284,7 @@ le4 = next(gen1) le5 = next(gen2) self.assertEqual(le1, le2) - self.assertFalse(le1 != le2) # noqa: H204 + self.assertFalse(le1 != le2) self.assertNotEqual(le1, le3) self.assertNotEqual(le1, site) self.assertIsInstance(le4, OtherLogEntry) diff --git a/tests/wbtypes_tests.py b/tests/wbtypes_tests.py index dc672a9..d44047c 100755 --- a/tests/wbtypes_tests.py +++ b/tests/wbtypes_tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Tests for the Wikidata parts of the page module.""" # -# (C) Pywikibot team, 2008-2024 +# (C) Pywikibot team, 2008-2025 # # Distributed under the terms of the MIT license. # @@ -510,11 +510,11 @@ self.assertGreaterEqual(t2, t1) self.assertNotEqual(t1, t2) self.assertNotEqual(t2, t1) - # Ignore H205: We specifically want to test the operator - self.assertFalse(t1 > t2) # noqa: H205 - self.assertFalse(t2 > t1) # noqa: H205 - self.assertFalse(t1 < t2) # noqa: H205 - self.assertFalse(t2 < t1) # noqa: H205 + # We specifically want to test the operator + self.assertFalse(t1 > t2) + self.assertFalse(t2 > t1) + self.assertFalse(t1 < t2) + self.assertFalse(t2 < t1)
def test_comparison_equal_instant(self): """Test the equal_instant method."""
pywikibot-commits@lists.wikimedia.org