From 4e43f9a845966056d8aaa9c87b47c6b247fd5786 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Sun, 15 Nov 2020 00:00:48 +0100 Subject: [PATCH] Update pre-commit repos (#379) Lint code according to updated versions --- .pre-commit-config.yaml | 12 +++++----- changes/377.feature | 1 + djangocms_installer/config/__init__.py | 32 ++++++++++++++++++++++---- djangocms_installer/django/__init__.py | 9 +++++--- djangocms_installer/main.py | 9 ++++++-- docs/conf.py | 18 +++++++++++++-- pyproject.toml | 2 +- tests/config.py | 10 +++++++- tests/django.py | 9 +++++--- tox.ini | 2 +- 10 files changed, 80 insertions(+), 24 deletions(-) create mode 100644 changes/377.feature diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ab6ebf5..514bb9bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: "(.idea|node_modules|.tox)" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.1.0 + rev: v3.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -17,15 +17,15 @@ repos: args: - --remove - repo: https://github.com/timothycrosley/isort - rev: "5.0.2" + rev: "5.6.4" hooks: - id: isort - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 20.8b1 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.3 + rev: 3.8.4 hooks: - id: flake8 additional_dependencies: @@ -40,14 +40,14 @@ repos: - flake8-tidy-imports - pep8-naming - repo: https://github.com/econchick/interrogate - rev: 1.2.0 + rev: 1.3.2 hooks: - id: interrogate args: - "-cpyproject.toml" - "--quiet" - repo: https://github.com/asottile/pyupgrade - rev: v2.6.2 + rev: v2.7.4 hooks: - id: pyupgrade args: diff --git a/changes/377.feature b/changes/377.feature new file mode 100644 index 00000000..699e629d --- /dev/null +++ b/changes/377.feature @@ -0,0 +1 @@ +Update pre-commit repos diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 34629689..e080532e 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -157,7 +157,11 @@ def parse(args): help="Use Bootstrap 4 Theme", ) parser.add_argument( - "--templates", dest="templates", action="store", default="no", help="Use custom template set", + "--templates", + dest="templates", + action="store", + default="no", + help="Use custom template set", ) parser.add_argument( "--starting-page", @@ -202,7 +206,12 @@ def parse(args): help="Don't run the configuration wizard, just use the " "provided values", ) parser.add_argument( - "--wizard", "-w", dest="wizard", action="store_true", default=False, help="Run the configuration wizard", + "--wizard", + "-w", + dest="wizard", + action="store_true", + default=False, + help="Run the configuration wizard", ) parser.add_argument( "--verbose", @@ -236,7 +245,11 @@ def parse(args): help="Don't install package dependencies", ) parser.add_argument( - "--no-plugins", dest="no_plugins", action="store_true", default=False, help="Don't install plugins", + "--no-plugins", + dest="no_plugins", + action="store_true", + default=False, + help="Don't install plugins", ) parser.add_argument( "--no-db-driver", @@ -254,7 +267,12 @@ def parse(args): help="Don't run syncdb / migrate after bootstrapping", ) parser.add_argument( - "--no-user", "-u", dest="no_user", action="store_true", default=False, help="Don't create the admin user", + "--no-user", + "-u", + dest="no_user", + action="store_true", + default=False, + help="Don't create the admin user", ) parser.add_argument( "--template", @@ -287,7 +305,11 @@ def parse(args): help="Delete project directory on creation failure.", ) parser.add_argument( - "--utc", dest="utc", action="store_true", default=False, help="Use UTC timezone.", + "--utc", + dest="utc", + action="store_true", + default=False, + help="Use UTC timezone.", ) if "--utc" in args: diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index dc3550dc..cf36fe1a 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -175,7 +175,8 @@ def patch_settings(config_data): if config_data.languages: original = original.replace( - "LANGUAGE_CODE = 'en-us'", "LANGUAGE_CODE = '{}'".format(config_data.languages[0]), + "LANGUAGE_CODE = 'en-us'", + "LANGUAGE_CODE = '{}'".format(config_data.languages[0]), ) if config_data.timezone: original = original.replace("TIME_ZONE = 'UTC'", "TIME_ZONE = '{}'".format(config_data.timezone)) @@ -229,7 +230,8 @@ def _build_settings(config_data): text.append( "MIDDLEWARE = [\n{}{}\n]".format( - spacer, (",\n" + spacer).join(["'{}'".format(var) for var in settings_data.MIDDLEWARE_CLASSES]), + spacer, + (",\n" + spacer).join(["'{}'".format(var) for var in settings_data.MIDDLEWARE_CLASSES]), ) ) @@ -323,7 +325,8 @@ def _build_settings(config_data): if config_data.filer: text.append( "THUMBNAIL_PROCESSORS = (\n{}{}\n)".format( - spacer, (",\n" + spacer).join(["'{}'".format(var) for var in settings_data.THUMBNAIL_PROCESSORS]), + spacer, + (",\n" + spacer).join(["'{}'".format(var) for var in settings_data.THUMBNAIL_PROCESSORS]), ) ) return "\n\n".join(text) diff --git a/djangocms_installer/main.py b/djangocms_installer/main.py index c74d5a1e..8013678a 100644 --- a/djangocms_installer/main.py +++ b/djangocms_installer/main.py @@ -24,11 +24,16 @@ def execute(): if not config_data.no_deps: if config_data.requirements_file: install.requirements( - config_data.requirements_file, config_data.pip_options, True, verbose=config_data.verbose, + config_data.requirements_file, + config_data.pip_options, + True, + verbose=config_data.verbose, ) else: install.requirements( - config_data.requirements, config_data.pip_options, verbose=config_data.verbose, + config_data.requirements, + config_data.pip_options, + verbose=config_data.verbose, ) sys.stdout.write("Dependencies installed\nCreating the project\n") install.check_install(config_data) diff --git a/docs/conf.py b/docs/conf.py index b0ba7efa..90531c76 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -199,7 +199,13 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ("index", "djangocms_installer.tex", "django CMS Installer Documentation", "Iacopo Spalletti", "manual",), + ( + "index", + "djangocms_installer.tex", + "django CMS Installer Documentation", + "Iacopo Spalletti", + "manual", + ), ] # The name of an image file (relative to this directory) to place at the top of @@ -227,7 +233,15 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [("index", "djangocms_installer", "django CMS Installer Documentation", ["Iacopo Spalletti"], 1,)] +man_pages = [ + ( + "index", + "djangocms_installer", + "django CMS Installer Documentation", + ["Iacopo Spalletti"], + 1, + ) +] # If true, show URL addresses after external links. # man_show_urls = False diff --git a/pyproject.toml b/pyproject.toml index 3e01b4aa..1c88cc63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 119 -target-version = ["py27"] +target-version = ["py36"] include = 'app_helper/*py' [tool.towncrier] diff --git a/tests/config.py b/tests/config.py index 7638c2f1..6a152942 100644 --- a/tests/config.py +++ b/tests/config.py @@ -949,7 +949,15 @@ def test_parse_config_file(self, *args): ("django_version", dj_lts_version), ), ), - ("config-03.ini", None, (("cms_version", "3.8"), ("i18n", "no"), ("django_version", dj_version),)), + ( + "config-03.ini", + None, + ( + ("cms_version", "3.8"), + ("i18n", "no"), + ("django_version", dj_version), + ), + ), ("config-04.ini", None, (("cms_version", "3.8"), ("use_timezone", "no"))), ("config-05.ini", None, (("cms_version", "3.8"), ("timezone", "Europe/London"))), ("config-06.ini", None, (("cms_version", "3.8"), ("reversion", "no"))), diff --git a/tests/django.py b/tests/django.py index c6a2048e..4927442f 100644 --- a/tests/django.py +++ b/tests/django.py @@ -180,7 +180,8 @@ def test_patch_22_settings(self): # checking for django options self.assertEqual( - project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, "media"), + project.settings.MEDIA_ROOT, + os.path.join(config_data.project_directory, "media"), ) self.assertEqual(project.settings.MEDIA_URL, "/media/") @@ -222,7 +223,8 @@ def test_patch_django_22_37(self): # checking for django options self.assertEqual( - project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, "media"), + project.settings.MEDIA_ROOT, + os.path.join(config_data.project_directory, "media"), ) self.assertEqual(project.settings.MEDIA_URL, "/media/") @@ -482,7 +484,8 @@ def test_patch(self): self.assertEqual(project.settings.TIME_ZONE, "Europe/Moscow") self.assertEqual(project.settings.LANGUAGE_CODE, "en") self.assertTrue( - project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, "media"), + project.settings.MEDIA_ROOT, + os.path.join(config_data.project_directory, "media"), ) self.assertEqual(project.settings.MEDIA_URL, "/media/") # diff --git a/tox.ini b/tox.ini index 2b3b75ec..57dd2d8f 100644 --- a/tox.ini +++ b/tox.ini @@ -53,7 +53,7 @@ skip_install = true [testenv:isort] commands = {envpython} -m isort -c --df djangocms_installer tests -deps = isort>5,<5.1 +deps = isort>5,<6 recreate = False skip_install = true