0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-21 18:09:02 +01:00

Upgrade ruff version (#10556)

Address "Unnecessary list comprehension" issues
This commit is contained in:
zerolab 2023-06-13 12:14:17 +01:00 committed by Matt Westcott
parent e6e392dc96
commit 61f0f4d362
7 changed files with 13 additions and 18 deletions

View File

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

View File

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

View File

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

View File

@ -84,7 +84,7 @@ class TestPageSearch(WagtailTestUtils, TransactionTestCase):
self.assertEqual(response.status_code, 200)
# 'pages' list in the response should contain root
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):
# SingleEventPage has a custom get_admin_display_title method; explorer should

View File

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

View File

@ -549,7 +549,7 @@ class BaseChoiceBlock(FieldBlock):
for v1, v2 in local_choices:
if isinstance(v2, (list, tuple)):
# 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:
break
else:

View File

@ -1832,7 +1832,7 @@ class TestCopyPage(TestCase):
# new tagged_item IDs should differ from old ones
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):
@ -1865,7 +1865,7 @@ class TestCopyPage(TestCase):
# new tagged_item IDs should differ from old ones
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):
@ -2421,7 +2421,7 @@ class TestCreateAlias(TestCase):
# new tagged_item IDs should differ from old ones
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):