Upgrade ruff version (#10556)

Address "Unnecessary list comprehension" issues
pull/10568/head
zerolab 2023-06-13 12:14:17 +01:00 zatwierdzone przez Matt Westcott
rodzic e6e392dc96
commit 61f0f4d362
7 zmienionych plików z 13 dodań i 18 usunięć

Wyświetl plik

@ -9,9 +9,8 @@ repos:
language_version: python3 language_version: python3
args: ['--target-version', 'py37'] args: ['--target-version', 'py37']
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version. rev: 'v0.0.272'
rev: 'v0.0.261'
hooks: hooks:
- id: ruff - id: ruff
args: [--fix, --exit-non-zero-on-fix] args: [--fix, --exit-non-zero-on-fix]

Wyświetl plik

@ -54,7 +54,7 @@ testing_extras = [
"coverage>=3.7.0", "coverage>=3.7.0",
"black==22.3.0", "black==22.3.0",
"doc8==0.8.1", "doc8==0.8.1",
"ruff==0.0.261", "ruff==0.0.272",
# For enforcing string formatting mechanism in source files # For enforcing string formatting mechanism in source files
"semgrep==1.3.0", "semgrep==1.3.0",
# For templates linting # For templates linting

Wyświetl plik

@ -268,10 +268,8 @@ def test_page_is_public(context, page):
) )
is_private = any( is_private = any(
[ page.path.startswith(restricted_path)
page.path.startswith(restricted_path) for restricted_path in context["request"].all_page_view_restriction_paths
for restricted_path in context["request"].all_page_view_restriction_paths
]
) )
return not is_private return not is_private

Wyświetl plik

@ -84,7 +84,7 @@ class TestPageSearch(WagtailTestUtils, TransactionTestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
# 'pages' list in the response should contain root # 'pages' list in the response should contain root
results = response.context["pages"] results = response.context["pages"]
self.assertTrue(any([r.slug == "root" for r in results])) self.assertTrue(any(r.slug == "root" for r in results))
def test_search_uses_admin_display_title_from_specific_class(self): def test_search_uses_admin_display_title_from_specific_class(self):
# SingleEventPage has a custom get_admin_display_title method; explorer should # SingleEventPage has a custom get_admin_display_title method; explorer should

Wyświetl plik

@ -356,7 +356,7 @@ class TestExtractPanelDefinitionsFromModelClass(TestCase):
# A class with a 'panels' property defined should return that list # A class with a 'panels' property defined should return that list
result = extract_panel_definitions_from_model_class(EventPageSpeaker) result = extract_panel_definitions_from_model_class(EventPageSpeaker)
self.assertEqual(len(result), 5) self.assertEqual(len(result), 5)
self.assertTrue(any([isinstance(panel, MultiFieldPanel) for panel in result])) self.assertTrue(any(isinstance(panel, MultiFieldPanel) for panel in result))
def test_exclude(self): def test_exclude(self):
panels = extract_panel_definitions_from_model_class(Site, exclude=["hostname"]) panels = extract_panel_definitions_from_model_class(Site, exclude=["hostname"])
@ -369,10 +369,8 @@ class TestExtractPanelDefinitionsFromModelClass(TestCase):
self.assertTrue( self.assertTrue(
any( any(
[ isinstance(panel, FieldPanel) and panel.field_name == "date_from"
isinstance(panel, FieldPanel) and panel.field_name == "date_from" for panel in panels
for panel in panels
]
) )
) )

Wyświetl plik

@ -549,7 +549,7 @@ class BaseChoiceBlock(FieldBlock):
for v1, v2 in local_choices: for v1, v2 in local_choices:
if isinstance(v2, (list, tuple)): if isinstance(v2, (list, tuple)):
# this is a named group, and v2 is the value list # this is a named group, and v2 is the value list
has_blank_choice = any([value in ("", None) for value, label in v2]) has_blank_choice = any(value in ("", None) for value, label in v2)
if has_blank_choice: if has_blank_choice:
break break
else: else:

Wyświetl plik

@ -1832,7 +1832,7 @@ class TestCopyPage(TestCase):
# new tagged_item IDs should differ from old ones # new tagged_item IDs should differ from old ones
self.assertTrue( self.assertTrue(
all([item_id not in old_tagged_item_ids for item_id in new_tagged_item_ids]) all(item_id not in old_tagged_item_ids for item_id in new_tagged_item_ids)
) )
def test_copy_subclassed_page_copies_tags(self): def test_copy_subclassed_page_copies_tags(self):
@ -1865,7 +1865,7 @@ class TestCopyPage(TestCase):
# new tagged_item IDs should differ from old ones # new tagged_item IDs should differ from old ones
self.assertTrue( self.assertTrue(
all([item_id not in old_tagged_item_ids for item_id in new_tagged_item_ids]) all(item_id not in old_tagged_item_ids for item_id in new_tagged_item_ids)
) )
def test_copy_page_with_m2m_relations(self): def test_copy_page_with_m2m_relations(self):
@ -2421,7 +2421,7 @@ class TestCreateAlias(TestCase):
# new tagged_item IDs should differ from old ones # new tagged_item IDs should differ from old ones
self.assertTrue( self.assertTrue(
all([item_id not in old_tagged_item_ids for item_id in new_tagged_item_ids]) all(item_id not in old_tagged_item_ids for item_id in new_tagged_item_ids)
) )
def test_create_alias_with_m2m_relations(self): def test_create_alias_with_m2m_relations(self):