Skip to content

Commit aa40748

Browse files
committed
black and isort
1 parent b285fa3 commit aa40748

File tree

7 files changed

+71
-89
lines changed

7 files changed

+71
-89
lines changed

debugtools/formatter.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@
5353
RuntimeError,
5454
)
5555

56-
RE_SQL_NL = re.compile(
57-
r"\b(FROM|LEFT OUTER|RIGHT|LEFT|INNER|OUTER|WHERE|ORDER BY|GROUP BY)\b"
58-
)
56+
RE_SQL_NL = re.compile(r"\b(FROM|LEFT OUTER|RIGHT|LEFT|INNER|OUTER|WHERE|ORDER BY|GROUP BY)\b")
5957
RE_SQL = re.compile(
6058
r"\b(SELECT|UPDATE|DELETE"
6159
r"|COUNT|AVG|MAX|MIN|CASE"
@@ -171,9 +169,7 @@ def _style_text(text):
171169
r"\g<1><small>&lt;<var>generator, use 'for' to traverse it</var>&gt;</small>",
172170
text,
173171
)
174-
text = RE_OBJECT_ADDRESS.sub(
175-
r"\g<1><small>&lt;<var>\g<2> object</var>&gt;</small>", text
176-
)
172+
text = RE_OBJECT_ADDRESS.sub(r"\g<1><small>&lt;<var>\g<2> object</var>&gt;</small>", text)
177173
text = RE_MANAGER.sub(
178174
r"\g<1><small>&lt;<var>manager, use <kbd>.all</kbd> to traverse it</var>&gt;</small>",
179175
text,
@@ -254,13 +250,9 @@ def _format_object(object):
254250
del attrs[name]
255251
elif hasattr(value, "__get__"):
256252
# fetched the descriptor, e.g. django.db.models.fields.related.ForeignRelatedObjectsDescriptor
257-
attrs[name] = value = _try_call(
258-
lambda: getattr(object, name), return_exceptions=True
259-
)
253+
attrs[name] = value = _try_call(lambda: getattr(object, name), return_exceptions=True)
260254
if isinstance(value, Manager):
261-
attrs[name] = LiteralStr(
262-
f"<{value.__class__.__name__} manager>"
263-
)
255+
attrs[name] = LiteralStr(f"<{value.__class__.__name__} manager>")
264256
elif isinstance(value, AttributeError):
265257
del attrs[name] # e.g. Manager isn't accessible via Model instances.
266258
elif isinstance(value, HANDLED_EXCEPTIONS):
@@ -436,8 +428,6 @@ def _format(self, object, stream, indent, allowance, context, level):
436428
Recursive part of the formatting
437429
"""
438430
try:
439-
PrettyPrinter._format(
440-
self, object, stream, indent, allowance, context, level
441-
)
431+
PrettyPrinter._format(self, object, stream, indent, allowance, context, level)
442432
except Exception as e:
443433
stream.write(_format_exception(e))

debugtools/middleware/xviewmiddleware.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import django
22

3-
from debugtools.utils.xview import (
4-
get_used_template,
5-
get_used_view_name,
6-
track_view_name,
7-
)
3+
from debugtools.utils.xview import get_used_template, get_used_view_name, track_view_name
84

95
if django.VERSION >= (1, 10):
106
from django.utils.deprecation import MiddlewareMixin

debugtools/panels/view.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
from debug_toolbar.panels import Panel
12
from django.db.models import Model
23
from django.forms import BaseForm
34
from django.forms.models import BaseFormSet
45
from django.utils.translation import gettext_lazy as _
56
from django.views.generic import View
67

7-
from debug_toolbar.panels import Panel
88
from debugtools.utils.xview import get_used_template, get_view_name
99

1010

@@ -40,9 +40,7 @@ def process_response(self, request, response):
4040
{
4141
"view_module": self.view_module,
4242
"view_name": self.view_name,
43-
"view_data": self._get_view_data(context_data)
44-
if context_data
45-
else None,
43+
"view_data": self._get_view_data(context_data) if context_data else None,
4644
"template": template,
4745
"template_choices": choices,
4846
}

debugtools/templatetags/debugtools_tags.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333

3434
PRE_ALERT_STYLE = """clear: both; font-family: Menlo,Monaco,"Courier new",monospace; color: #C09853; background-color: #FCF8E3; border: 1px solid #FBEED5; border-radius: 4px 4px 4px 4px; font-size: 12.025px; text-align: left; line-height: 18px; margin-bottom: 18px; padding: 8px 35px 8px 14px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); white-space: pre-wrap; word-break: normal; word-wrap: normal;""" # different word-wrap then Twitter Bootstrap
3535

36-
CONTEXT_TITLE = '<h6 style="color: #999999; font-size: 11px; margin: 9px 0;">TEMPLATE CONTEXT SCOPE:</h6>\n'
36+
CONTEXT_TITLE = (
37+
'<h6 style="color: #999999; font-size: 11px; margin: 9px 0;">TEMPLATE CONTEXT SCOPE:</h6>\n'
38+
)
3739

3840
CONTEXT_BLOCK = (
3941
"<pre style='{style}; position: relative;'>"
@@ -45,9 +47,7 @@
4547

4648
ERROR_TYPE_BLOCK = "<pre style='{style}'>{error}</pre>"
4749

48-
OBJECT_TYPE_BLOCK = (
49-
"<pre style='{style}'>{name} = <small>{type}</small>:\n{value}</pre>"
50-
)
50+
OBJECT_TYPE_BLOCK = "<pre style='{style}'>{name} = <small>{type}</small>:\n{value}</pre>"
5151

5252

5353
register = Library()
@@ -84,9 +84,7 @@ def print_context(self, context):
8484
if len(context_scope) <= 3 and dump1.count("<br />") > 20:
8585
(dump1, dump2) = (dump2, dump1)
8686

87-
text.append(
88-
CONTEXT_BLOCK.format(style=PRE_STYLE, num=i, dump1=dump1, dump2=dump2)
89-
)
87+
text.append(CONTEXT_BLOCK.format(style=PRE_STYLE, num=i, dump1=dump1, dump2=dump2))
9088
return "".join(text)
9189

9290
def print_variables(self, context):
@@ -101,9 +99,7 @@ def print_variables(self, context):
10199
if isinstance(expr.var, Variable):
102100
data = expr.var.resolve(context)
103101
else:
104-
data = expr.resolve(
105-
context
106-
) # could return TEMPLATE_STRING_IF_INVALID
102+
data = expr.resolve(context) # could return TEMPLATE_STRING_IF_INVALID
107103
except VariableDoesNotExist as e:
108104
# Failed to resolve, display exception inline
109105
keys = []
@@ -124,9 +120,7 @@ def print_variables(self, context):
124120

125121
# At top level, prefix class name if it's a longer result
126122
if isinstance(data, SHORT_NAME_TYPES):
127-
text.append(
128-
BASIC_TYPE_BLOCK.format(style=PRE_STYLE, name=name, value=textdata)
129-
)
123+
text.append(BASIC_TYPE_BLOCK.format(style=PRE_STYLE, name=name, value=textdata))
130124
else:
131125
text.append(
132126
OBJECT_TYPE_BLOCK.format(
@@ -158,6 +152,4 @@ def format_sql(sql):
158152

159153

160154
def _format_exception(exception):
161-
return '<span style="color: #B94A48;">{}</span>'.format(
162-
escape(f"<{exception}>")
163-
)
155+
return '<span style="color: #B94A48;">{}</span>'.format(escape(f"<{exception}>"))

debugtools/utils/xview.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ def get_used_template(response):
5959
else:
6060
# Template object.
6161
filename = _get_template_filename(template)
62-
template_name = (
63-
f"<template object from {filename}>"
64-
if filename
65-
else "<template object>"
66-
)
62+
template_name = f"<template object from {filename}>" if filename else "<template object>"
6763
return template_name, None
6864

6965

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[tool.isort]
2+
profile = "black"
3+
line_length = 99
4+
5+
[tool.black]
6+
line-length = 99
7+
exclude = '''
8+
/(
9+
\.git
10+
| \.venv
11+
| \.tox
12+
| dist
13+
)/
14+
'''

setup.py

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env python
2-
from setuptools import setup, find_packages
3-
from os import path
42
import codecs
53
import os
64
import re
75
import sys
6+
from os import path
7+
8+
from setuptools import find_packages, setup
89

910

1011
def read(*parts):
1112
file_path = path.join(path.dirname(__file__), *parts)
12-
return codecs.open(file_path, encoding='utf-8').read()
13+
return codecs.open(file_path, encoding="utf-8").read()
1314

1415

1516
def find_version(*parts):
@@ -21,48 +22,43 @@ def find_version(*parts):
2122

2223

2324
setup(
24-
name='django-debugtools',
25-
version=find_version('debugtools', '__init__.py'),
26-
license='Apache 2.0',
27-
28-
description='A toolbox of small utilities to assist Django development',
29-
long_description=read('README.rst'),
30-
31-
author='Diederik van der Boor',
32-
author_email='[email protected]',
33-
34-
url='https://github.com/edoburu/django-debugtools',
35-
download_url='https://github.com/edoburu/django-debugtools/zipball/master',
36-
37-
packages=find_packages(exclude=('example*',)),
25+
name="django-debugtools",
26+
version=find_version("debugtools", "__init__.py"),
27+
license="Apache 2.0",
28+
description="A toolbox of small utilities to assist Django development",
29+
long_description=read("README.rst"),
30+
author="Diederik van der Boor",
31+
author_email="[email protected]",
32+
url="https://github.com/edoburu/django-debugtools",
33+
download_url="https://github.com/edoburu/django-debugtools/zipball/master",
34+
packages=find_packages(exclude=("example*",)),
3835
include_package_data=True,
39-
4036
zip_safe=False,
4137
classifiers=[
42-
'Development Status :: 5 - Production/Stable',
43-
'Environment :: Web Environment',
44-
'Intended Audience :: Developers',
45-
'License :: OSI Approved :: Apache Software License',
46-
'Operating System :: OS Independent',
47-
'Programming Language :: Python',
48-
'Programming Language :: Python :: 2',
49-
'Programming Language :: Python :: 2.6',
50-
'Programming Language :: Python :: 2.7',
51-
'Programming Language :: Python :: 3',
52-
'Programming Language :: Python :: 3.3',
53-
'Programming Language :: Python :: 3.4',
54-
'Programming Language :: Python :: 3.5',
55-
'Programming Language :: Python :: 3.6',
56-
'Framework :: Django',
57-
'Framework :: Django :: 1.4',
58-
'Framework :: Django :: 1.5',
59-
'Framework :: Django :: 1.6',
60-
'Framework :: Django :: 1.7',
61-
'Framework :: Django :: 1.8',
62-
'Framework :: Django :: 1.9',
63-
'Framework :: Django :: 1.10',
64-
'Framework :: Django :: 1.11',
65-
'Framework :: Django :: 2.0',
66-
'Topic :: Software Development :: Debuggers',
67-
]
38+
"Development Status :: 5 - Production/Stable",
39+
"Environment :: Web Environment",
40+
"Intended Audience :: Developers",
41+
"License :: OSI Approved :: Apache Software License",
42+
"Operating System :: OS Independent",
43+
"Programming Language :: Python",
44+
"Programming Language :: Python :: 2",
45+
"Programming Language :: Python :: 2.6",
46+
"Programming Language :: Python :: 2.7",
47+
"Programming Language :: Python :: 3",
48+
"Programming Language :: Python :: 3.3",
49+
"Programming Language :: Python :: 3.4",
50+
"Programming Language :: Python :: 3.5",
51+
"Programming Language :: Python :: 3.6",
52+
"Framework :: Django",
53+
"Framework :: Django :: 1.4",
54+
"Framework :: Django :: 1.5",
55+
"Framework :: Django :: 1.6",
56+
"Framework :: Django :: 1.7",
57+
"Framework :: Django :: 1.8",
58+
"Framework :: Django :: 1.9",
59+
"Framework :: Django :: 1.10",
60+
"Framework :: Django :: 1.11",
61+
"Framework :: Django :: 2.0",
62+
"Topic :: Software Development :: Debuggers",
63+
],
6864
)

0 commit comments

Comments
 (0)