Remove #noqa from most common imports and add them to import_exceptions
We have a lot of import with #noqa that is there to ignore h302, because it's traditional to import and use a name directly, instead of a whole module. This hides other errors and gives people the impression that it's actually fine to import non-modules, you just have to slap #noqa on those lines. I went through the code and identified about a dozen names that are most commonly imported this way. I remove the #noqa tag from them, and added them to the list in import_exceptions. I also removed a few unused imports that were revealed in the process. Change-Id: I27afb8e2b1d4759ec974ded9464d8f010312ee78
This commit is contained in:
parent
022abc0aa8
commit
12c9cc335f
|
@ -14,7 +14,7 @@
|
|||
|
||||
import logging
|
||||
|
||||
from django.conf import settings # noqa
|
||||
from django.conf import settings
|
||||
from heatclient import client as heat_client
|
||||
from openstack_dashboard.api import base
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import json
|
|||
import logging
|
||||
import re
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.decorators.debug import sensitive_variables # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
|
|
|
@ -17,7 +17,7 @@ import logging
|
|||
import re
|
||||
import urlparse
|
||||
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.template.defaultfilters import register # noqa
|
||||
|
||||
from openstack_dashboard.api import swift
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import horizon
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
from django.http import Http404 # noqa
|
||||
from django.template.defaultfilters import timesince # noqa
|
||||
from django.template.defaultfilters import title # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import messages
|
||||
from horizon import tables
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from horizon import messages
|
||||
from horizon import tabs
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import json
|
||||
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.core.urlresolvers import reverse
|
||||
from django import http
|
||||
|
||||
from mox import IsA # noqa
|
||||
|
|
|
@ -21,10 +21,10 @@ from horizon import tables
|
|||
from horizon import tabs
|
||||
from horizon.utils import memoized
|
||||
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.core.urlresolvers import reverse_lazy # noqa
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.http import HttpResponse # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views import generic
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
from functools import wraps # noqa
|
||||
import os
|
||||
|
||||
from django.conf import settings # noqa
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.middleware import AuthenticationMiddleware # noqa
|
||||
from django.contrib.messages.storage import default_storage # noqa
|
||||
from django.core.handlers import wsgi
|
||||
|
|
18
tox.ini
18
tox.ini
|
@ -42,3 +42,21 @@ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,p
|
|||
# H702 Formatting operation should be outside of localization method call
|
||||
# H803 git commit title should not end with period (disabled on purpose, see bug #1236621)
|
||||
ignore = E127,E128,H701,H702,H803
|
||||
|
||||
[hacking]
|
||||
import_exceptions = collections.defaultdict,
|
||||
django.conf.settings,
|
||||
django.core.urlresolvers.reverse,
|
||||
django.core.urlresolvers.reverse_lazy,
|
||||
django.template.loader.render_to_string,
|
||||
django.utils.datastructures.SortedDict,
|
||||
django.utils.encoding.force_unicode,
|
||||
django.utils.html.conditional_escape,
|
||||
django.utils.html.escape,
|
||||
django.utils.http.urlencode,
|
||||
django.utils.safestring.mark_safe,
|
||||
django.utils.translation.pgettext_lazy,
|
||||
django.utils.translation.ugettext_lazy,
|
||||
django.utils.translation.ungettext_lazy,
|
||||
operator.attrgetter,
|
||||
StringIO.StringIO
|
||||
|
|
Loading…
Reference in New Issue