Browse Source

dev: lint debug_toolbar

David Cramer 7 years ago
parent
commit
6e99ac3ac6

+ 1 - 0
src/debug_toolbar/compat.py

@@ -4,6 +4,7 @@ This file exists to contain all Django and Python compatibility issues.
 In order to avoid circular references, nothing should be imported from
 debug_toolbar.
 """
+from __future__ import absolute_import
 
 import django
 from django.conf import settings

+ 1 - 0
src/debug_toolbar/management/__init__.py

@@ -0,0 +1 @@
+from __future__ import absolute_import

+ 1 - 0
src/debug_toolbar/management/commands/__init__.py

@@ -0,0 +1 @@
+from __future__ import absolute_import

+ 1 - 1
src/debug_toolbar/management/commands/debugsqlshell.py

@@ -20,7 +20,7 @@ class PrintQueryWrapper(db_backends_util.CursorDebugWrapper):
             end_time = time()
             duration = (end_time - start_time) * 1000
             formatted_sql = sqlparse.format(raw_sql, reindent=True)
-            print('%s [%.2fms]' % (formatted_sql, duration))
+            print('%s [%.2fms]' % (formatted_sql, duration))  # NOQA
 
 
 db_backends_util.CursorDebugWrapper = PrintQueryWrapper

+ 3 - 1
src/debug_toolbar/panels/cache.py

@@ -1,6 +1,7 @@
 from __future__ import absolute_import, unicode_literals
 
 import inspect
+import six
 import sys
 import time
 
@@ -49,11 +50,12 @@ def send_signal(method):
 
 class CacheStatTracker(BaseCache):
     """A small class used to track cache calls."""
+
     def __init__(self, cache):
         self.cache = cache
 
     def __repr__(self):
-        return str("<CacheStatTracker for %s>") % repr(self.cache)
+        return six.text_type("<CacheStatTracker for %s>") % repr(self.cache)
 
     def _get_func_info(self):
         frame = sys._getframe(3)

+ 3 - 1
src/debug_toolbar/panels/headers.py

@@ -1,5 +1,7 @@
 from __future__ import absolute_import, unicode_literals
 
+import six
+
 from django.utils.translation import ugettext_lazy as _
 
 from debug_toolbar.compat import OrderedDict
@@ -57,7 +59,7 @@ class HeadersPanel(Panel):
 def is_http_header(wsgi_key):
     # The WSGI spec says that keys should be str objects in the environ dict,
     # but this isn't true in practice. See issues #449 and #482.
-    return isinstance(wsgi_key, str) and wsgi_key.startswith('HTTP_')
+    return isinstance(wsgi_key, six.string_types) and wsgi_key.startswith('HTTP_')
 
 
 def unmangle(wsgi_key):

+ 6 - 2
src/debug_toolbar/panels/profiling.py

@@ -1,5 +1,7 @@
 from __future__ import absolute_import, division, unicode_literals
 
+import six
+
 from django.utils.translation import ugettext_lazy as _
 from django.utils.safestring import mark_safe
 from debug_toolbar.panels import Panel
@@ -86,7 +88,8 @@ class FunctionCall(object):
                                func,
                                self.depth + 1,
                                stats=stats,
-                               id=str(self.id) + '_' + str(i),
+                               id=six.text_type(self.id) +
+                               '_' + six.text_type(i),
                                parent_ids=self.parent_ids + [self.id],
                                hsv=(h1, s1, 1))
 
@@ -140,7 +143,8 @@ class ProfilingPanel(Panel):
             for subfunc in func.subfuncs():
                 if subfunc.stats[3] >= cum_time:
                     func.has_subfuncs = True
-                    self.add_node(func_list, subfunc, max_depth, cum_time=cum_time)
+                    self.add_node(func_list, subfunc,
+                                  max_depth, cum_time=cum_time)
 
     def process_response(self, request, response):
         if not hasattr(self, 'profiler'):

+ 2 - 1
src/debug_toolbar/panels/signals.py

@@ -1,5 +1,6 @@
 from __future__ import absolute_import, unicode_literals
 
+import six
 
 from django.core.signals import (
     request_started, request_finished, got_request_exception)
@@ -72,7 +73,7 @@ class SignalsPanel(Panel):
                     continue
 
                 receiver = getattr(receiver, '__wraps__', receiver)
-                receiver_name = getattr(receiver, '__name__', str(receiver))
+                receiver_name = getattr(receiver, '__name__', six.text_type(receiver))
                 if getattr(receiver, '__self__', None) is not None:
                     receiver_class_name = getattr(receiver.__self__, '__class__', type).__name__
                     text = "%s.%s" % (receiver_class_name, receiver_name)

+ 2 - 1
src/debug_toolbar/panels/versions.py

@@ -1,5 +1,6 @@
 from __future__ import absolute_import, unicode_literals
 
+import six
 import sys
 
 import django
@@ -67,5 +68,5 @@ class VersionsPanel(Panel):
         else:
             return
         if isinstance(version, (list, tuple)):
-            version = '.'.join(str(o) for o in version)
+            version = '.'.join(six.text_type(o) for o in version)
         return version

+ 1 - 0
src/debug_toolbar/templatetags/__init__.py

@@ -0,0 +1 @@
+from __future__ import absolute_import

Some files were not shown because too many files changed in this diff