From bef56330617e61931e7d69d9366283be10249338 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Mon, 30 Jul 2018 15:17:31 +0200 Subject: [PATCH] Lint properly, reorganizing some imports and removing unused ones --- docs/development/testing.rst | 1 - docs/development/testproject.rst | 1 - docs/index.rst | 1 - docs/settings.rst | 1 - src/wiki/__init__.py | 1 - src/wiki/conf/settings.py | 1 - src/wiki/plugins/images/apps.py | 2 +- src/wiki/plugins/images/models.py | 4 ++-- src/wiki/plugins/macros/mdx/toc.py | 3 +-- src/wiki/plugins/redlinks/mdx/redlinks.py | 7 ++++--- src/wiki/sites.py | 2 +- src/wiki/static/wiki/bootstrap/LICENSE | 2 +- .../wiki/bootstrap/fonts/glyphicons-halflings-regular.svg | 2 +- .../static/wiki/font-awesome/font/fontawesome-webfont.svg | 2 +- src/wiki/urls.py | 3 +-- tests/core/test_checks.py | 2 +- tests/core/test_markdown.py | 3 ++- tests/plugins/attachments/test_models.py | 2 +- tests/plugins/images/test_forms.py | 1 - tests/plugins/images/test_views.py | 5 +---- tests/plugins/links/test_urlize.py | 6 ++---- tests/testdata/urls.py | 1 - 22 files changed, 20 insertions(+), 33 deletions(-) diff --git a/docs/development/testing.rst b/docs/development/testing.rst index 59f9faf0..e5acf66f 100644 --- a/docs/development/testing.rst +++ b/docs/development/testing.rst @@ -62,4 +62,3 @@ fixtures for tests e.g. a root article. Javascript, and can be tested using the fast WebTest method, rather than relying on the slow and fragile Selenium method. Selenium tests are not run by default. - diff --git a/docs/development/testproject.rst b/docs/development/testproject.rst index 49b82768..ee1d3403 100644 --- a/docs/development/testproject.rst +++ b/docs/development/testproject.rst @@ -8,4 +8,3 @@ an sqlite database. Login for django admin is ``admin:admin``. This project should always be maintained, but please do not commit changes to the SQLite database as we only care about its contents in case data models are changed. - diff --git a/docs/index.rst b/docs/index.rst index 4d8a3e6c..d5be0b00 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -26,4 +26,3 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` - diff --git a/docs/settings.rst b/docs/settings.rst index e6256c61..c0f1a2cf 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -33,4 +33,3 @@ Plugin macros .. automodule:: wiki.plugins.macros.settings :members: - diff --git a/src/wiki/__init__.py b/src/wiki/__init__.py index 336c1768..8a341786 100644 --- a/src/wiki/__init__.py +++ b/src/wiki/__init__.py @@ -17,7 +17,6 @@ from wiki.core.version import get_version - default_app_config = 'wiki.apps.WikiConfig' VERSION = (0, 4, 0, 'alpha', 5) diff --git a/src/wiki/conf/settings.py b/src/wiki/conf/settings.py index 228816c2..c558bf7f 100644 --- a/src/wiki/conf/settings.py +++ b/src/wiki/conf/settings.py @@ -1,5 +1,4 @@ import bleach -from django.apps import apps from django.conf import settings as django_settings from django.contrib.messages import constants as messages from django.core.files.storage import default_storage diff --git a/src/wiki/plugins/images/apps.py b/src/wiki/plugins/images/apps.py index c17597f4..81ff64be 100644 --- a/src/wiki/plugins/images/apps.py +++ b/src/wiki/plugins/images/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -from django.utils.translation import gettext_lazy as _ from django.core.checks import register +from django.utils.translation import gettext_lazy as _ from . import checks diff --git a/src/wiki/plugins/images/models.py b/src/wiki/plugins/images/models.py index 49ddbcce..8441a97c 100644 --- a/src/wiki/plugins/images/models.py +++ b/src/wiki/plugins/images/models.py @@ -107,9 +107,9 @@ class ImageRevision(RevisionPluginRevision): def on_image_revision_delete(instance, *args, **kwargs): if not instance.image: return - # Remove image file + # Remove image file instance.image.delete(save=False) - + try: path = instance.image.path.split("/")[:-1] except NotImplemented: diff --git a/src/wiki/plugins/macros/mdx/toc.py b/src/wiki/plugins/macros/mdx/toc.py index 5a4e9c5b..35ae297c 100644 --- a/src/wiki/plugins/macros/mdx/toc.py +++ b/src/wiki/plugins/macros/mdx/toc.py @@ -1,7 +1,6 @@ import re -from markdown.extensions.toc import TocTreeprocessor, TocExtension, slugify -from markdown.util import etree +from markdown.extensions.toc import TocExtension, TocTreeprocessor, slugify from wiki.plugins.macros import settings HEADER_ID_PREFIX = "wiki-toc-" diff --git a/src/wiki/plugins/redlinks/mdx/redlinks.py b/src/wiki/plugins/redlinks/mdx/redlinks.py index e9967b97..807fbc77 100644 --- a/src/wiki/plugins/redlinks/mdx/redlinks.py +++ b/src/wiki/plugins/redlinks/mdx/redlinks.py @@ -1,6 +1,7 @@ -from urllib.parse import urlparse, urljoin -from markdown.treeprocessors import Treeprocessor +from urllib.parse import urljoin, urlparse + from markdown.extensions import Extension +from markdown.treeprocessors import Treeprocessor from wiki.models import URLPath @@ -22,7 +23,7 @@ def urljoin_internal(base, url): res1 = urljoin(canary1 + base, url) res2 = urljoin(canary2 + base, url) if res1.startswith(canary1) and res2.startswith(canary2): - return res1[len(canary1) :] + return res1[len(canary1):] class LinkTreeprocessor(Treeprocessor): diff --git a/src/wiki/sites.py b/src/wiki/sites.py index bbbcb715..fbfb824c 100644 --- a/src/wiki/sites.py +++ b/src/wiki/sites.py @@ -1,8 +1,8 @@ from django.apps import apps from django.utils.functional import LazyObject from django.utils.module_loading import import_string -from wiki.conf import settings from wiki.compat import include, url +from wiki.conf import settings from wiki.core.plugins import registry diff --git a/src/wiki/static/wiki/bootstrap/LICENSE b/src/wiki/static/wiki/bootstrap/LICENSE index 2bb9ad24..d9a10c0d 100644 --- a/src/wiki/static/wiki/bootstrap/LICENSE +++ b/src/wiki/static/wiki/bootstrap/LICENSE @@ -173,4 +173,4 @@ incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS \ No newline at end of file + END OF TERMS AND CONDITIONS diff --git a/src/wiki/static/wiki/bootstrap/fonts/glyphicons-halflings-regular.svg b/src/wiki/static/wiki/bootstrap/fonts/glyphicons-halflings-regular.svg index 94fb5490..187805af 100644 --- a/src/wiki/static/wiki/bootstrap/fonts/glyphicons-halflings-regular.svg +++ b/src/wiki/static/wiki/bootstrap/fonts/glyphicons-halflings-regular.svg @@ -285,4 +285,4 @@ - \ No newline at end of file + diff --git a/src/wiki/static/wiki/font-awesome/font/fontawesome-webfont.svg b/src/wiki/static/wiki/font-awesome/font/fontawesome-webfont.svg index d907b25a..b6129693 100644 --- a/src/wiki/static/wiki/font-awesome/font/fontawesome-webfont.svg +++ b/src/wiki/static/wiki/font-awesome/font/fontawesome-webfont.svg @@ -517,4 +517,4 @@ - \ No newline at end of file + diff --git a/src/wiki/urls.py b/src/wiki/urls.py index 966f5941..c1f542a4 100644 --- a/src/wiki/urls.py +++ b/src/wiki/urls.py @@ -1,11 +1,10 @@ from django.utils.module_loading import import_string +from wiki import sites from wiki.compat import include, url from wiki.conf import settings from wiki.core.plugins import registry -from wiki import sites from wiki.views import accounts, article, deleted_list - urlpatterns = [ url(r'^', sites.site.urls), ] diff --git a/tests/core/test_checks.py b/tests/core/test_checks.py index a6466534..7e87418c 100644 --- a/tests/core/test_checks.py +++ b/tests/core/test_checks.py @@ -3,7 +3,7 @@ import copy from django.conf import settings from django.core.checks import Error, registry from django.test import TestCase -from wiki.checks import OBSOLETE_INSTALLED_APPS, REQUIRED_CONTEXT_PROCESSORS, REQUIRED_INSTALLED_APPS, Tags +from wiki.checks import REQUIRED_CONTEXT_PROCESSORS, REQUIRED_INSTALLED_APPS, Tags def _remove(settings, arg): diff --git a/tests/core/test_markdown.py b/tests/core/test_markdown.py index 09b99516..48b9cdd8 100644 --- a/tests/core/test_markdown.py +++ b/tests/core/test_markdown.py @@ -1,6 +1,7 @@ +from unittest.mock import patch + import markdown from django.test import TestCase -from unittest.mock import patch from wiki.core.markdown import ArticleMarkdown from wiki.core.markdown.mdx.codehilite import WikiCodeHiliteExtension from wiki.core.markdown.mdx.responsivetable import ResponsiveTableExtension diff --git a/tests/plugins/attachments/test_models.py b/tests/plugins/attachments/test_models.py index 5c5ef4e3..9441a38f 100644 --- a/tests/plugins/attachments/test_models.py +++ b/tests/plugins/attachments/test_models.py @@ -1,5 +1,5 @@ from tests.base import RequireRootArticleMixin, TestBase -from wiki.plugins.attachments.models import AttachmentRevision, Attachment +from wiki.plugins.attachments.models import Attachment, AttachmentRevision class AttachmentRevisionTests(RequireRootArticleMixin, TestBase): diff --git a/tests/plugins/images/test_forms.py b/tests/plugins/images/test_forms.py index fdb0f0f5..075ae8f5 100644 --- a/tests/plugins/images/test_forms.py +++ b/tests/plugins/images/test_forms.py @@ -1,6 +1,5 @@ from django.test import TestCase from django.utils.translation import gettext - from wiki.plugins.images.forms import PurgeForm diff --git a/tests/plugins/images/test_views.py b/tests/plugins/images/test_views.py index a89d410a..20619120 100644 --- a/tests/plugins/images/test_views.py +++ b/tests/plugins/images/test_views.py @@ -9,10 +9,7 @@ from wiki.models import URLPath from wiki.plugins.images import models from wiki.plugins.images.wiki_plugin import ImagePlugin -from ...base import ( - ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin, - wiki_override_settings, -) +from ...base import ArticleWebTestUtils, DjangoClientTestBase, RequireRootArticleMixin, wiki_override_settings class ImageTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase): diff --git a/tests/plugins/links/test_urlize.py b/tests/plugins/links/test_urlize.py index 31acb240..2098da84 100644 --- a/tests/plugins/links/test_urlize.py +++ b/tests/plugins/links/test_urlize.py @@ -1,11 +1,9 @@ import html -import markdown from unittest import mock +import markdown import pytest - -from wiki.plugins.links.mdx.urlize import makeExtension, UrlizeExtension - +from wiki.plugins.links.mdx.urlize import UrlizeExtension, makeExtension # Template accepts two strings - href value and link text value. EXPECTED_LINK_TEMPLATE = ( diff --git a/tests/testdata/urls.py b/tests/testdata/urls.py index 9dc28bc7..2ad87359 100644 --- a/tests/testdata/urls.py +++ b/tests/testdata/urls.py @@ -3,7 +3,6 @@ from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from wiki.compat import include, url - urlpatterns = [ url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', admin.site.urls), -- 2.45.2