Apply several ruff SIM rules (#37283)

* Apply ruff SIM118 fix

Signed-off-by: cyy <cyyever@outlook.com>

* Apply ruff SIM910 fix

Signed-off-by: cyy <cyyever@outlook.com>

* Apply ruff SIM101 fix

Signed-off-by: cyy <cyyever@outlook.com>

* Format code

Signed-off-by: cyy <cyyever@outlook.com>

* More fixes

Signed-off-by: cyy <cyyever@outlook.com>

---------

Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
Yuanyuan Chen
2025-07-29 19:40:34 +08:00
committed by GitHub
parent cf97f6cfd1
commit 95faabf0a6
391 changed files with 762 additions and 788 deletions

View File

@@ -154,7 +154,7 @@ class HfArgumentParserTest(unittest.TestCase):
# Choices with mixed type have custom function as "type"
# So we need to compare results directly for equality
if xx.get("choices", None) and yy.get("choices", None):
if xx.get("choices") and yy.get("choices"):
for expected_choice in yy["choices"] + xx["choices"]:
self.assertEqual(xx["type"](expected_choice), yy["type"](expected_choice))
del xx["type"], yy["type"]

View File

@@ -71,7 +71,7 @@ class TestImportStructures(unittest.TestCase):
}
self.assertEqual(len(import_structure.keys()), len(valid_frozensets.keys()))
for _frozenset in valid_frozensets.keys():
for _frozenset in valid_frozensets:
self.assertTrue(_frozenset in import_structure)
self.assertListEqual(list(import_structure[_frozenset].keys()), list(valid_frozensets[_frozenset].keys()))
for module, objects in valid_frozensets[_frozenset].items():