From 85d5d033d8e49dd04241676ac406ede23e7dc2b0 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Thu, 4 Jun 2020 12:22:40 +0200 Subject: [PATCH] Remove isort, call pre-commit from tox lint env, fix up remaining flake8 --- setup.cfg | 14 +------------- setup.py | 4 ++-- src/wiki/conf/settings.py | 2 +- src/wiki/core/diff.py | 2 +- .../plugins/editsection/markdown_extensions.py | 8 ++++---- src/wiki/views/article.py | 2 +- tests/plugins/images/test_views.py | 18 +++++++++--------- tests/settings.py | 2 +- tox.ini | 3 ++- 9 files changed, 22 insertions(+), 33 deletions(-) diff --git a/setup.cfg b/setup.cfg index b8b43391..b7f11353 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,10 +2,8 @@ universal = 0 [flake8] -# ignore = E501 W503 W504 - +max-line-length = 213 # black style -max-line-length = 120 extend-ignore = E203 max-complexity = 10 @@ -16,13 +14,3 @@ description-file = README.rst [aliases] test=pytest - -[isort] -combine_as_imports = true -default_section = THIRDPARTY -include_trailing_comma = true -line_length = 160 -multi_line_output = 5 -not_skip = __init__.py -skip = docs/conf.py -indent = 4 diff --git a/setup.py b/setup.py index b23cd30f..6a6fb2e5 100755 --- a/setup.py +++ b/setup.py @@ -42,15 +42,15 @@ test_requirements = [ test_lint_requirements = [ "flake8>=3.7,<3.8", - "flake8-isort", "black", # Just use the latest + "pre-commit", ] setup_requirements = [ "pytest-runner", ] -development_requirements = test_requirements + test_lint_requirements + ["pre-commit"] +development_requirements = test_requirements + test_lint_requirements extras_requirements = { "devel": development_requirements, diff --git a/src/wiki/conf/settings.py b/src/wiki/conf/settings.py index 4b8e6273..7c0a4fa2 100644 --- a/src/wiki/conf/settings.py +++ b/src/wiki/conf/settings.py @@ -52,7 +52,7 @@ MARKDOWN_KWARGS = { "markdown.extensions.abbr", "markdown.extensions.sane_lists", ], - "extension_configs": {"wiki.plugins.macros.mdx.toc": {"title": _("Contents")},}, + "extension_configs": {"wiki.plugins.macros.mdx.toc": {"title": _("Contents")}}, } MARKDOWN_KWARGS.update(getattr(django_settings, "WIKI_MARKDOWN_KWARGS", {})) diff --git a/src/wiki/core/diff.py b/src/wiki/core/diff.py index 4279972b..02ff8196 100644 --- a/src/wiki/core/diff.py +++ b/src/wiki/core/diff.py @@ -6,6 +6,6 @@ def simple_merge(txt1, txt2): differ = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK) diff = differ.compare(txt1.splitlines(1), txt2.splitlines(1)) - content = "".join([l[2:] for l in diff]) + content = "".join([_l[2:] for _l in diff]) return content diff --git a/src/wiki/plugins/editsection/markdown_extensions.py b/src/wiki/plugins/editsection/markdown_extensions.py index edd487af..1c476f91 100644 --- a/src/wiki/plugins/editsection/markdown_extensions.py +++ b/src/wiki/plugins/editsection/markdown_extensions.py @@ -61,8 +61,8 @@ class EditSectionProcessor(Treeprocessor): if level <= sec_level: return sec_start, self.headers[cur_header].start - for l in range(level, last_level): - cur_pos[l] = 0 + for _l in range(level, last_level): + cur_pos[_l] = 0 cur_pos[level - 1] += 1 last_level = level @@ -92,8 +92,8 @@ class EditSectionProcessor(Treeprocessor): continue level = int(match.group(1)) - for l in range(level, last_level): - cur_pos[l] = 0 + for _l in range(level, last_level): + cur_pos[_l] = 0 cur_pos[level - 1] += 1 last_level = level location = "-".join(map(str, cur_pos)) diff --git a/src/wiki/views/article.py b/src/wiki/views/article.py index b2ace1a8..a22041ec 100644 --- a/src/wiki/views/article.py +++ b/src/wiki/views/article.py @@ -823,7 +823,7 @@ class ChangeRevisionView(RedirectView): _( "The article %(title)s is now set to display revision #%(revision_number)d" ) - % {"title": revision.title, "revision_number": revision.revision_number,}, + % {"title": revision.title, "revision_number": revision.revision_number}, ) diff --git a/tests/plugins/images/test_views.py b/tests/plugins/images/test_views.py index dc20db4d..c83069b5 100644 --- a/tests/plugins/images/test_views.py +++ b/tests/plugins/images/test_views.py @@ -104,10 +104,10 @@ class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestB output = self.get_article("[image:1]", True) image_rev = models.Image.objects.get().current_revision.imagerevision expected = ( - '
' - '' - 'test\.gif' - '
' + r'
' + r'' + r'test\.gif' + r'
' ) self.assertRegexpMatches(output, expected) @@ -115,10 +115,10 @@ class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestB output = self.get_article("[image:1 align:right size:large]", True) image_rev = models.Image.objects.get().current_revision.imagerevision expected = ( - '
' - '' - 'test\.gif' - '
' + r'
' + r'' + r'test\.gif' + r'
' ) self.assertRegexpMatches(output, expected) @@ -277,7 +277,7 @@ class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestB image = models.Image.objects.get() url = reverse( "wiki:images_add_revision", - kwargs={"article_id": self.root_article, "image_id": image.pk, "path": "",}, + kwargs={"article_id": self.root_article, "image_id": image.pk, "path": ""}, ) response = self.client.post(url, data={"image": self.generate_photo_file()}) self.assertRedirects(response, "{}?next={}".format(reverse("wiki:login"), url)) diff --git a/tests/settings.py b/tests/settings.py index 2a3e30fc..2e36ad76 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -6,7 +6,7 @@ TESTS_DATA_ROOT = os.path.dirname(__file__) MEDIA_ROOT = os.path.join(TESTS_DATA_ROOT, "media") -DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3",}} +DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3"}} DEBUG = True AUTH_USER_MODEL = "testdata.CustomUser" diff --git a/tox.ini b/tox.ini index 72a7132b..f000214d 100644 --- a/tox.ini +++ b/tox.ini @@ -50,4 +50,5 @@ deps = .[testlint] commands = flake8 src/wiki flake8 tests/ - black --check --diff src tests setup.py + pre-commit install -f --install-hooks + pre-commit run --all-files --show-diff-on-failure -- 2.45.2