~netlandish/django-wiki

85d5d033d8e49dd04241676ac406ede23e7dc2b0 — Benjamin Bach 4 years ago 9c993c4
Remove isort, call pre-commit from tox lint env, fix up remaining flake8
M setup.cfg => setup.cfg +1 -13
@@ 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

M setup.py => setup.py +2 -2
@@ 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,

M src/wiki/conf/settings.py => src/wiki/conf/settings.py +1 -1
@@ 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", {}))


M src/wiki/core/diff.py => src/wiki/core/diff.py +1 -1
@@ 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

M src/wiki/plugins/editsection/markdown_extensions.py => src/wiki/plugins/editsection/markdown_extensions.py +4 -4
@@ 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))

M src/wiki/views/article.py => src/wiki/views/article.py +1 -1
@@ 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},
        )



M tests/plugins/images/test_views.py => tests/plugins/images/test_views.py +9 -9
@@ 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 = (
            '<figure class="thumbnail">'
            '<a href="' + image_rev.image.name + '">'
            '<img alt="test\.gif" src="cache/.*\.jpg">'
            '</a><figcaption class="caption"></figcaption></figure>'
            r'<figure class="thumbnail">'
            r'<a href="' + image_rev.image.name + '">'
            r'<img alt="test\.gif" src="cache/.*\.jpg">'
            r'</a><figcaption class="caption"></figcaption></figure>'
        )
        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 = (
            '<figure class="thumbnail float-right">'
            '<a href="' + image_rev.image.name + '">'
            '<img alt="test\.gif" src="cache/.*\.jpg"></a>'
            '<figcaption class="caption"></figcaption></figure>'
            r'<figure class="thumbnail float-right">'
            r'<a href="' + image_rev.image.name + '">'
            r'<img alt="test\.gif" src="cache/.*\.jpg"></a>'
            r'<figcaption class="caption"></figcaption></figure>'
        )
        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))

M tests/settings.py => tests/settings.py +1 -1
@@ 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"

M tox.ini => tox.ini +2 -1
@@ 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