From 5e941d1733aa801dbbf2c21cb9369686d99b1feb Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Mon, 9 May 2022 17:04:07 +0100 Subject: [PATCH 1/9] port-feat: pre-commit config added from the v3 worksream --- .pre-commit-config.yaml | 34 ++++++++++++++++++++++++++++++++++ CHANGELOG.rst | 1 + 2 files changed, 35 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..2e93adc0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +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"] + + - 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..f7c8dd67 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog Unreleased ========== +* port-feat: pre-commit config added from the v3 worksream * fix: Added test coverage to admin preview view 4.0.0.dev4 (2022-02-03) From ea7085850b8786be08ee53d1c8477895efdb8a97 Mon Sep 17 00:00:00 2001 From: Aiky30 Date: Mon, 9 May 2022 17:07:07 +0100 Subject: [PATCH 2/9] Fix typo int he changelog --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f7c8dd67..dd7ab2f3 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,7 +4,7 @@ Changelog Unreleased ========== -* port-feat: pre-commit config added from the v3 worksream +* 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) From e068a9d7fc3f80d1ae546d54978fdb9ed63bd195 Mon Sep 17 00:00:00 2001 From: Aiky30 Date: Mon, 9 May 2022 17:07:32 +0100 Subject: [PATCH 3/9] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e93adc0..9306761e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: rev: '1.4.0' hooks: - id: django-upgrade - args: [--target-version, "2.2"] + args: [--target-version, "1.11"] - repo: https://github.com/PyCQA/flake8 rev: 4.0.1 From 69b72847267754ef351980c0011a9e12894ac768 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 16:08:11 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_plugins.py | 3 ++- tests/utils/factories.py | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) 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 From 17c1cdf147f62459373222d359feb7de0e297ba8 Mon Sep 17 00:00:00 2001 From: Aiky30 Date: Mon, 9 May 2022 17:32:16 +0100 Subject: [PATCH 5/9] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9306761e..2e93adc0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: rev: '1.4.0' hooks: - id: django-upgrade - args: [--target-version, "1.11"] + args: [--target-version, "2.2"] - repo: https://github.com/PyCQA/flake8 rev: 4.0.1 From abc3643f29288ec02b1d95330817a21c47e2faaf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 16:32:24 +0000 Subject: [PATCH 6/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- djangocms_snippet/admin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/djangocms_snippet/admin.py b/djangocms_snippet/admin.py index 6769d9ce..e0b728da 100644 --- a/djangocms_snippet/admin.py +++ b/djangocms_snippet/admin.py @@ -1,5 +1,4 @@ from django.conf import settings -from django.conf.urls import url from django.contrib import admin from django.contrib.admin import helpers from django.contrib.admin.exceptions import DisallowedModelAdminToField @@ -7,6 +6,7 @@ from django.contrib.admin.utils import flatten_fieldsets, unquote from django.db import models from django.forms import Textarea +from django.urls import path from django.utils.translation import gettext as _ from cms.utils.permissions import get_model_permission_codename @@ -142,8 +142,8 @@ 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( - r"^(?P\d+)/preview/$", + path( + '/preview/', self.admin_site.admin_view(self.preview_view), name="{}_{}_preview".format(*info), ), From 5b12766844b11b6728b61b3ae3a01903fb9b6348 Mon Sep 17 00:00:00 2001 From: Aiky30 Date: Tue, 10 May 2022 12:43:37 +0100 Subject: [PATCH 7/9] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e93adc0..9306761e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: rev: '1.4.0' hooks: - id: django-upgrade - args: [--target-version, "2.2"] + args: [--target-version, "1.11"] - repo: https://github.com/PyCQA/flake8 rev: 4.0.1 From 184cf7815a7eb9d47bf6e338f7716be246d75fca Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 10 May 2022 12:50:21 +0100 Subject: [PATCH 8/9] Undo a chnage i didn't make --- djangocms_snippet/admin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/djangocms_snippet/admin.py b/djangocms_snippet/admin.py index e0b728da..0b5f40de 100644 --- a/djangocms_snippet/admin.py +++ b/djangocms_snippet/admin.py @@ -1,4 +1,5 @@ from django.conf import settings +from django.conf.urls import url from django.contrib import admin from django.contrib.admin import helpers from django.contrib.admin.exceptions import DisallowedModelAdminToField @@ -6,7 +7,6 @@ from django.contrib.admin.utils import flatten_fieldsets, unquote from django.db import models from django.forms import Textarea -from django.urls import path from django.utils.translation import gettext as _ from cms.utils.permissions import get_model_permission_codename @@ -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 [ - path( - '/preview/', + 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): """ From c86568a43dba9859f3d888f3d54f159d65bfcdd7 Mon Sep 17 00:00:00 2001 From: Andrew Aikman Date: Tue, 10 May 2022 13:41:19 +0100 Subject: [PATCH 9/9] Remove precommit formatting script --- .pre-commit-config.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9306761e..37516d4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,13 @@ repos: # hooks: # - id: pyupgrade # args: ["--py37-plus"] - - - repo: https://github.com/adamchainz/django-upgrade - rev: '1.4.0' - hooks: - - id: django-upgrade - args: [--target-version, "1.11"] +# +# 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