Skip to content

Commit cb41b2e

Browse files
albertywavelis
authored andcommitted
Fix non line-length pep8 issues in silk directory
1 parent f1ef5d1 commit cb41b2e

File tree

9 files changed

+17
-18
lines changed

9 files changed

+17
-18
lines changed

silk/collector.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,14 @@ def _get_objects(self, typ):
7878
self._raise_not_configured(
7979
'Attempt to access %s without initialisation.' % typ
8080
)
81-
if not typ in objects:
81+
if typ not in objects:
8282
objects[typ] = {}
8383
return objects[typ]
8484

8585
@property
8686
def profiles(self):
8787
return self._get_objects(TYP_PROFILES)
8888

89-
@property
90-
def silk_queries(self):
91-
return self._get_objects('silk_queries')
92-
9389
def configure(self, request=None):
9490
silky_config = SilkyConfig()
9591

@@ -119,7 +115,7 @@ def register_objects(self, typ, *args):
119115
self._raise_not_configured(
120116
'Attempt to register object of type %s without initialisation. '
121117
)
122-
if not typ in objects:
118+
if typ not in objects:
123119
self.objects[typ] = {}
124120
self.objects[typ][ident] = arg
125121

silk/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class BaseProfile(models.Model):
295295
request = ForeignKey(
296296
Request, null=True, blank=True, db_index=True,
297297
on_delete=models.CASCADE,
298-
)
298+
)
299299
time_taken = FloatField(blank=True, null=True)
300300

301301
class Meta:

silk/profiling/profiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def _finalise_queries(self):
118118
def __exit__(self, exc_type, exc_val, exc_tb):
119119
if self._silk_installed() and self._should_profile():
120120
with silk_meta_profiler():
121-
start_time = None
122121
exception_raised = exc_type is not None
123122
self.profile['exception_raised'] = exception_raised
124123
self.profile['end_time'] = timezone.now()
@@ -177,7 +176,7 @@ def wrapped_target(*args, **kwargs):
177176
return target
178177

179178
def distinct_queries(self):
180-
queries = [x for x in self._queries_after if not x in self._queries_before]
179+
queries = [x for x in self._queries_after if x not in self._queries_before]
181180
return queries
182181

183182

silk/request_filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def filters_from_request(request):
213213
if splt[0].startswith('filter'):
214214
ident = splt[1]
215215
typ = splt[2]
216-
if not ident in raw_filters:
216+
if ident not in raw_filters:
217217
raw_filters[ident] = {}
218218
raw_filters[ident][typ] = request.POST[key]
219219
filters = {}

silk/templatetags/silk_filters.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
register = Library()
1010

1111

12+
def _no_op(x):
13+
return x
14+
15+
1216
def _esc_func(autoescape):
1317
if autoescape:
14-
esc = conditional_escape
15-
else:
16-
esc = lambda x: x
17-
return esc
18+
return conditional_escape
19+
return _no_op
1820

1921

2022
@stringfilter
@@ -86,6 +88,7 @@ def body_filter(value):
8688
else:
8789
return value
8890

91+
8992
spacify.needs_autoescape = True
9093
filepath_urlify.needs_autoescape = True
9194
register.filter(spacify)

silk/templatetags/silk_inclusion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def heading(text):
3434
def code(lines, actual_line):
3535
return {'code': lines, 'actual_line': [x.strip() for x in actual_line]}
3636

37+
3738
register.inclusion_tag('silk/inclusion/request_summary.html')(request_summary)
3839
register.inclusion_tag('silk/inclusion/profile_summary.html')(profile_summary)
3940
register.inclusion_tag('silk/inclusion/code.html')(code)

silk/views/requests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class RequestsView(View):
3939
},
4040
'db_time': {
4141
'label': 'Time on queries',
42-
'additional_query_filter': lambda x: x.annotate(db_time=Sum('queries__time_taken')) \
43-
.filter(db_time__gte=0)
42+
'additional_query_filter': lambda x: x.annotate(db_time=Sum('queries__time_taken'))
43+
.filter(db_time__gte=0)
4444
},
4545
}
4646
order_dir = {

silk/views/sql_detail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def get(self, request, *_, **kwargs):
4545
line_num = int(request.GET.get('line_num', 0))
4646
tb = sql_query.traceback_ln_only
4747
str, files = self._urlify(tb)
48-
if file_path and not file_path in files:
48+
if file_path and file_path not in files:
4949
raise PermissionDenied
5050
tb = [mark_safe(x) for x in str.split('\n')]
5151
context = {

silk/views/summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
except ImportError:
44
# Django>=1.8
55
from django.template.context_processors import csrf
6-
6+
77
from django.db.models import Avg, Count, Sum, Max
88
from django.shortcuts import render
99
from django.utils.decorators import method_decorator

0 commit comments

Comments
 (0)