diff --git a/silk/code_generation/django_test_client.py b/silk/code_generation/django_test_client.py index d3972921..2b901e95 100644 --- a/silk/code_generation/django_test_client.py +++ b/silk/code_generation/django_test_client.py @@ -20,8 +20,7 @@ def _encode_query_params(query_params): query_params = urlencode(query_params) except TypeError: pass - query_params = '?' + query_params - return query_params + return '?' + query_params def gen(path, diff --git a/silk/models.py b/silk/models.py index 46377d04..27163ef3 100644 --- a/silk/models.py +++ b/silk/models.py @@ -211,8 +211,7 @@ def bulk_create(self, *args, **kwargs): for r in requests: r.num_sql_queries = F('num_sql_queries') + request_counter[r.pk] r.save() - save = super(SQLQueryManager, self).bulk_create(*args, **kwargs) - return save + return super(SQLQueryManager, self).bulk_create(*args, **kwargs) class SQLQuery(models.Model): @@ -327,5 +326,4 @@ def is_context_profile(self): @property def time_spent_on_sql_queries(self): - time_spent = sum(x.time_taken for x in self.queries.all()) - return time_spent + return sum(x.time_taken for x in self.queries.all()) diff --git a/silk/profiling/dynamic.py b/silk/profiling/dynamic.py index d29dc8f1..fadfa4f9 100644 --- a/silk/profiling/dynamic.py +++ b/silk/profiling/dynamic.py @@ -150,8 +150,7 @@ def _new_func_from_source(source, func): combined.update(locals) Logger.debug('New src_str:\n %s' % src_str) six.exec_(src_str, combined, context) - new_func = context[func.__name__] - return new_func + return context[func.__name__] def _inject_context_manager_func(func, start_line, end_line, name): diff --git a/silk/profiling/profiler.py b/silk/profiling/profiler.py index f5e4b580..fbd4f3b2 100644 --- a/silk/profiling/profiler.py +++ b/silk/profiling/profiler.py @@ -176,8 +176,7 @@ def wrapped_target(*args, **kwargs): return target def distinct_queries(self): - queries = [x for x in self._queries_after if x not in self._queries_before] - return queries + return [x for x in self._queries_after if x not in self._queries_before] @silk_profile() diff --git a/silk/views/profiling.py b/silk/views/profiling.py index 3938fc85..beb95e1b 100644 --- a/silk/views/profiling.py +++ b/silk/views/profiling.py @@ -38,8 +38,7 @@ def _get_distinct_values(self, field, silk_request): function_names.remove('') except ValueError: pass - function_names = [''] + function_names - return function_names + return [''] + function_names def _get_function_names(self, silk_request=None): return self._get_distinct_values('func_name', silk_request) diff --git a/silk/views/requests.py b/silk/views/requests.py index a925aed4..da4c1644 100644 --- a/silk/views/requests.py +++ b/silk/views/requests.py @@ -70,7 +70,7 @@ def _get_paths(self): def _get_status_codes(self): return [x['status_code'] for x in Response.objects.values('status_code').distinct()] - def _get_methods(selfs): + def _get_methods(self): return [x['method'] for x in Request.objects.values('method').distinct()] def _get_objects(self, show=None, order_by=None, order_dir=None, path=None, filters=None):