diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..37516d4a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: +# Need to drop python 3.5 and 3.6 before we include python upgrade +# - repo: https://github.com/asottile/pyupgrade +# rev: v2.31.0 +# hooks: +# - id: pyupgrade +# args: ["--py37-plus"] +# +# FIXME: Should be enabled for codebases that are minimum django 2.2+ +# - repo: https://github.com/adamchainz/django-upgrade +# rev: '1.4.0' +# hooks: +# - id: django-upgrade +# args: [--target-version, "2.2"] + + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + + - repo: https://github.com/asottile/yesqa + rev: v1.3.0 + hooks: + - id: yesqa + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: check-merge-conflict + - id: mixed-line-ending + + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7172ddb3..dd7ab2f3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog Unreleased ========== +* port-feat: pre-commit config added from the v3 workstream * fix: Added test coverage to admin preview view 4.0.0.dev4 (2022-02-03) diff --git a/djangocms_snippet/admin.py b/djangocms_snippet/admin.py index 6769d9ce..0b5f40de 100644 --- a/djangocms_snippet/admin.py +++ b/djangocms_snippet/admin.py @@ -142,12 +142,12 @@ def preview_view(self, request, snippet_id=None, form_url='', extra_context=None def get_urls(self): info = self.model._meta.app_label, self.model._meta.model_name return [ - url( + url( r"^(?P\d+)/preview/$", self.admin_site.admin_view(self.preview_view), name="{}_{}_preview".format(*info), - ), - ] + super().get_urls() + ), + ] + super().get_urls() def has_delete_permission(self, request, obj=None): """ diff --git a/tests/test_plugins.py b/tests/test_plugins.py index d6ab5182..210af121 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -5,9 +5,10 @@ from cms.test_utils.testcases import CMSTestCase from cms.toolbar.utils import get_object_edit_url, get_object_structure_url -from djangocms_snippet.models import Snippet, SnippetGrouper from djangocms_versioning.models import Version +from djangocms_snippet.models import Snippet, SnippetGrouper + from .utils.factories import SnippetWithVersionFactory diff --git a/tests/utils/factories.py b/tests/utils/factories.py index af8d18ce..9d6210c6 100644 --- a/tests/utils/factories.py +++ b/tests/utils/factories.py @@ -6,11 +6,8 @@ from cms.models import Placeholder import factory -from factory.fuzzy import ( - FuzzyInteger, - FuzzyText, -) from djangocms_versioning.models import Version +from factory.fuzzy import FuzzyInteger, FuzzyText from djangocms_snippet.models import Snippet, SnippetGrouper, SnippetPtr