Removed unnecessary assignments in various code.
This commit is contained in:
parent
80482e9249
commit
8b3f1c35dd
|
@ -610,7 +610,7 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
|
|
||||||
info = self.model._meta.app_label, self.model._meta.model_name
|
info = self.model._meta.app_label, self.model._meta.model_name
|
||||||
|
|
||||||
urlpatterns = [
|
return [
|
||||||
path('', wrap(self.changelist_view), name='%s_%s_changelist' % info),
|
path('', wrap(self.changelist_view), name='%s_%s_changelist' % info),
|
||||||
path('add/', wrap(self.add_view), name='%s_%s_add' % info),
|
path('add/', wrap(self.add_view), name='%s_%s_add' % info),
|
||||||
path('autocomplete/', wrap(self.autocomplete_view), name='%s_%s_autocomplete' % info),
|
path('autocomplete/', wrap(self.autocomplete_view), name='%s_%s_autocomplete' % info),
|
||||||
|
@ -622,7 +622,6 @@ class ModelAdmin(BaseModelAdmin):
|
||||||
pattern_name='%s:%s_%s_change' % ((self.admin_site.name,) + info)
|
pattern_name='%s:%s_%s_change' % ((self.admin_site.name,) + info)
|
||||||
))),
|
))),
|
||||||
]
|
]
|
||||||
return urlpatterns
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def urls(self):
|
def urls(self):
|
||||||
|
|
|
@ -66,5 +66,4 @@ def render_flatpage(request, f):
|
||||||
f.title = mark_safe(f.title)
|
f.title = mark_safe(f.title)
|
||||||
f.content = mark_safe(f.content)
|
f.content = mark_safe(f.content)
|
||||||
|
|
||||||
response = HttpResponse(template.render({'flatpage': f}, request))
|
return HttpResponse(template.render({'flatpage': f}, request))
|
||||||
return response
|
|
||||||
|
|
|
@ -69,8 +69,7 @@ def check_string(result, func, cargs, offset=-1, str_result=False):
|
||||||
# ### Envelope checking ###
|
# ### Envelope checking ###
|
||||||
def check_envelope(result, func, cargs, offset=-1):
|
def check_envelope(result, func, cargs, offset=-1):
|
||||||
"Check a function that returns an OGR Envelope by reference."
|
"Check a function that returns an OGR Envelope by reference."
|
||||||
env = ptr_byref(cargs, offset)
|
return ptr_byref(cargs, offset)
|
||||||
return env
|
|
||||||
|
|
||||||
|
|
||||||
# ### Geometry error-checking routines ###
|
# ### Geometry error-checking routines ###
|
||||||
|
|
|
@ -97,8 +97,7 @@ class BaseCache:
|
||||||
if version is None:
|
if version is None:
|
||||||
version = self.version
|
version = self.version
|
||||||
|
|
||||||
new_key = self.key_func(key, self.key_prefix, version)
|
return self.key_func(key, self.key_prefix, version)
|
||||||
return new_key
|
|
||||||
|
|
||||||
def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
|
def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -300,8 +300,7 @@ class Command(BaseCommand):
|
||||||
dirs.append(app_dir)
|
dirs.append(app_dir)
|
||||||
dirs.extend(fixture_dirs)
|
dirs.extend(fixture_dirs)
|
||||||
dirs.append('')
|
dirs.append('')
|
||||||
dirs = [os.path.abspath(os.path.realpath(d)) for d in dirs]
|
return [os.path.abspath(os.path.realpath(d)) for d in dirs]
|
||||||
return dirs
|
|
||||||
|
|
||||||
def parse_name(self, fixture_name):
|
def parse_name(self, fixture_name):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -14,8 +14,7 @@ def sql_flush(style, connection, only_django=False, reset_sequences=True, allow_
|
||||||
else:
|
else:
|
||||||
tables = connection.introspection.table_names(include_views=False)
|
tables = connection.introspection.table_names(include_views=False)
|
||||||
seqs = connection.introspection.sequence_list() if reset_sequences else ()
|
seqs = connection.introspection.sequence_list() if reset_sequences else ()
|
||||||
statements = connection.ops.sql_flush(style, tables, seqs, allow_cascade)
|
return connection.ops.sql_flush(style, tables, seqs, allow_cascade)
|
||||||
return statements
|
|
||||||
|
|
||||||
|
|
||||||
def emit_pre_migrate_signal(verbosity, interactive, db, **kwargs):
|
def emit_pre_migrate_signal(verbosity, interactive, db, **kwargs):
|
||||||
|
|
|
@ -198,14 +198,13 @@ class DatabaseOperations(BaseDatabaseOperations):
|
||||||
# Simulate TRUNCATE CASCADE by recursively collecting the tables
|
# Simulate TRUNCATE CASCADE by recursively collecting the tables
|
||||||
# referencing the tables to be flushed.
|
# referencing the tables to be flushed.
|
||||||
tables = set(chain.from_iterable(self._references_graph(table) for table in tables))
|
tables = set(chain.from_iterable(self._references_graph(table) for table in tables))
|
||||||
sql = ['%s %s %s;' % (
|
# Note: No requirement for reset of auto-incremented indices (cf. other
|
||||||
|
# sql_flush() implementations). Just return SQL at this point
|
||||||
|
return ['%s %s %s;' % (
|
||||||
style.SQL_KEYWORD('DELETE'),
|
style.SQL_KEYWORD('DELETE'),
|
||||||
style.SQL_KEYWORD('FROM'),
|
style.SQL_KEYWORD('FROM'),
|
||||||
style.SQL_FIELD(self.quote_name(table))
|
style.SQL_FIELD(self.quote_name(table))
|
||||||
) for table in tables]
|
) for table in tables]
|
||||||
# Note: No requirement for reset of auto-incremented indices (cf. other
|
|
||||||
# sql_flush() implementations). Just return SQL at this point
|
|
||||||
return sql
|
|
||||||
|
|
||||||
def adapt_datetimefield_value(self, value):
|
def adapt_datetimefield_value(self, value):
|
||||||
if value is None:
|
if value is None:
|
||||||
|
|
|
@ -134,9 +134,10 @@ class BaseFormSet:
|
||||||
def forms(self):
|
def forms(self):
|
||||||
"""Instantiate forms at first property access."""
|
"""Instantiate forms at first property access."""
|
||||||
# DoS protection is included in total_form_count()
|
# DoS protection is included in total_form_count()
|
||||||
forms = [self._construct_form(i, **self.get_form_kwargs(i))
|
return [
|
||||||
for i in range(self.total_form_count())]
|
self._construct_form(i, **self.get_form_kwargs(i))
|
||||||
return forms
|
for i in range(self.total_form_count())
|
||||||
|
]
|
||||||
|
|
||||||
def get_form_kwargs(self, index):
|
def get_form_kwargs(self, index):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -360,8 +360,7 @@ class LazyStream:
|
||||||
remaining -= len(emitting)
|
remaining -= len(emitting)
|
||||||
yield emitting
|
yield emitting
|
||||||
|
|
||||||
out = b''.join(parts())
|
return b''.join(parts())
|
||||||
return out
|
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -64,8 +64,7 @@ def _unsalt_cipher_token(token):
|
||||||
token = token[CSRF_SECRET_LENGTH:]
|
token = token[CSRF_SECRET_LENGTH:]
|
||||||
chars = CSRF_ALLOWED_CHARS
|
chars = CSRF_ALLOWED_CHARS
|
||||||
pairs = zip((chars.index(x) for x in token), (chars.index(x) for x in salt))
|
pairs = zip((chars.index(x) for x in token), (chars.index(x) for x in salt))
|
||||||
secret = ''.join(chars[x - y] for x, y in pairs) # Note negative values are ok
|
return ''.join(chars[x - y] for x, y in pairs) # Note negative values are ok
|
||||||
return secret
|
|
||||||
|
|
||||||
|
|
||||||
def _get_new_csrf_token():
|
def _get_new_csrf_token():
|
||||||
|
|
|
@ -80,8 +80,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||||
"""
|
"""
|
||||||
template = self.resolve_template(self.template_name)
|
template = self.resolve_template(self.template_name)
|
||||||
context = self.resolve_context(self.context_data)
|
context = self.resolve_context(self.context_data)
|
||||||
content = template.render(context, self._request)
|
return template.render(context, self._request)
|
||||||
return content
|
|
||||||
|
|
||||||
def add_post_render_callback(self, callback):
|
def add_post_render_callback(self, callback):
|
||||||
"""Add a new post-rendering callback.
|
"""Add a new post-rendering callback.
|
||||||
|
|
|
@ -306,8 +306,7 @@ def get_runner(settings, test_runner_class=None):
|
||||||
else:
|
else:
|
||||||
test_module_name = '.'
|
test_module_name = '.'
|
||||||
test_module = __import__(test_module_name, {}, {}, test_path[-1])
|
test_module = __import__(test_module_name, {}, {}, test_path[-1])
|
||||||
test_runner = getattr(test_module, test_path[-1])
|
return getattr(test_module, test_path[-1])
|
||||||
return test_runner
|
|
||||||
|
|
||||||
|
|
||||||
class TestContextDecorator:
|
class TestContextDecorator:
|
||||||
|
@ -757,7 +756,7 @@ def require_jinja2(test_func):
|
||||||
Django template engine for a test or skip it if Jinja2 isn't available.
|
Django template engine for a test or skip it if Jinja2 isn't available.
|
||||||
"""
|
"""
|
||||||
test_func = skipIf(jinja2 is None, "this test requires jinja2")(test_func)
|
test_func = skipIf(jinja2 is None, "this test requires jinja2")(test_func)
|
||||||
test_func = override_settings(TEMPLATES=[{
|
return override_settings(TEMPLATES=[{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
}, {
|
}, {
|
||||||
|
@ -765,7 +764,6 @@ def require_jinja2(test_func):
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {'keep_trailing_newline': True},
|
'OPTIONS': {'keep_trailing_newline': True},
|
||||||
}])(test_func)
|
}])(test_func)
|
||||||
return test_func
|
|
||||||
|
|
||||||
|
|
||||||
class override_script_prefix(TestContextDecorator):
|
class override_script_prefix(TestContextDecorator):
|
||||||
|
|
|
@ -251,11 +251,10 @@ class AdminEmailHandlerTest(SimpleTestCase):
|
||||||
def get_admin_email_handler(self, logger):
|
def get_admin_email_handler(self, logger):
|
||||||
# AdminEmailHandler does not get filtered out
|
# AdminEmailHandler does not get filtered out
|
||||||
# even with DEBUG=True.
|
# even with DEBUG=True.
|
||||||
admin_email_handler = [
|
return [
|
||||||
h for h in logger.handlers
|
h for h in logger.handlers
|
||||||
if h.__class__.__name__ == "AdminEmailHandler"
|
if h.__class__.__name__ == "AdminEmailHandler"
|
||||||
][0]
|
][0]
|
||||||
return admin_email_handler
|
|
||||||
|
|
||||||
def test_fail_silently(self):
|
def test_fail_silently(self):
|
||||||
admin_email_handler = self.get_admin_email_handler(self.logger)
|
admin_email_handler = self.get_admin_email_handler(self.logger)
|
||||||
|
|
|
@ -117,8 +117,7 @@ def return_text_file(request):
|
||||||
else:
|
else:
|
||||||
charset = settings.DEFAULT_CHARSET
|
charset = settings.DEFAULT_CHARSET
|
||||||
|
|
||||||
response = HttpResponse(request.body, status=200, content_type='text/plain; charset=%s' % charset)
|
return HttpResponse(request.body, status=200, content_type='text/plain; charset=%s' % charset)
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
def check_headers(request):
|
def check_headers(request):
|
||||||
|
|
Loading…
Reference in New Issue