diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 715839536e..73f9fc886d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/setup.py b/setup.py index 937101d01b..0f2715309c 100755 --- a/setup.py +++ b/setup.py @@ -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 diff --git a/wagtail/admin/templatetags/wagtailadmin_tags.py b/wagtail/admin/templatetags/wagtailadmin_tags.py index 78f2db4cc5..ed53684bd7 100644 --- a/wagtail/admin/templatetags/wagtailadmin_tags.py +++ b/wagtail/admin/templatetags/wagtailadmin_tags.py @@ -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 diff --git a/wagtail/admin/tests/pages/test_page_search.py b/wagtail/admin/tests/pages/test_page_search.py index 98c94e5175..46f9e2fe35 100644 --- a/wagtail/admin/tests/pages/test_page_search.py +++ b/wagtail/admin/tests/pages/test_page_search.py @@ -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 diff --git a/wagtail/admin/tests/test_edit_handlers.py b/wagtail/admin/tests/test_edit_handlers.py index eac7f2344b..d96498c02f 100644 --- a/wagtail/admin/tests/test_edit_handlers.py +++ b/wagtail/admin/tests/test_edit_handlers.py @@ -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 ) ) diff --git a/wagtail/blocks/field_block.py b/wagtail/blocks/field_block.py index 0c8418f3c6..f3a212bfcc 100644 --- a/wagtail/blocks/field_block.py +++ b/wagtail/blocks/field_block.py @@ -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: diff --git a/wagtail/tests/test_page_model.py b/wagtail/tests/test_page_model.py index 22f7abdd48..ea2e8722ed 100644 --- a/wagtail/tests/test_page_model.py +++ b/wagtail/tests/test_page_model.py @@ -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):