summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Jakimiak <pj306228@students.mimuw.edu.pl>2015-05-13 20:51:18 +0200
committerPiotr Jakimiak <pj306228@students.mimuw.edu.pl>2015-05-13 20:51:18 +0200
commit4157c502a5202798d0f73645181cb82aa71d34d9 (patch)
tree78c99c7fd271f6c25a71b2ccf781ab7928396677
parentf61c4f490dc4c8ec6ba94ad4f40247db2425fc3e (diff)
Removed unnecessary arguments in .get method calls
-rw-r--r--django/contrib/admin/filters.py11
-rw-r--r--django/contrib/admin/options.py2
-rw-r--r--django/contrib/auth/forms.py2
-rw-r--r--django/contrib/auth/management/commands/createsuperuser.py2
-rw-r--r--django/contrib/flatpages/forms.py4
-rw-r--r--django/contrib/gis/db/models/query.py10
-rw-r--r--django/contrib/gis/feeds.py2
-rw-r--r--django/contrib/gis/gdal/geomtype.py2
-rw-r--r--django/contrib/gis/geoip/base.py2
-rw-r--r--django/contrib/gis/geoip/libgeoip.py2
-rw-r--r--django/contrib/gis/geos/linestring.py2
-rw-r--r--django/contrib/postgres/forms/array.py2
-rw-r--r--django/contrib/sessions/backends/cache.py2
-rw-r--r--django/contrib/sessions/backends/cached_db.py2
-rw-r--r--django/contrib/sessions/middleware.py2
-rw-r--r--django/contrib/sitemaps/__init__.py8
-rw-r--r--django/contrib/staticfiles/finders.py2
-rw-r--r--django/contrib/staticfiles/storage.py4
-rw-r--r--django/core/cache/backends/base.py2
-rw-r--r--django/core/cache/backends/memcached.py2
-rw-r--r--django/core/management/commands/check.py2
-rw-r--r--django/core/management/commands/makemigrations.py4
-rw-r--r--django/core/serializers/xml_serializer.py4
-rw-r--r--django/db/migrations/autodetector.py14
-rw-r--r--django/db/models/fields/__init__.py8
-rw-r--r--django/db/models/fields/files.py2
-rw-r--r--django/db/models/query.py2
-rw-r--r--django/forms/models.py2
-rw-r--r--django/forms/widgets.py22
-rw-r--r--django/http/request.py2
-rw-r--r--django/middleware/cache.py4
-rw-r--r--django/middleware/clickjacking.py2
-rw-r--r--django/template/base.py4
-rw-r--r--django/template/defaulttags.py2
-rw-r--r--django/test/client.py2
-rw-r--r--django/utils/cache.py4
-rw-r--r--django/views/decorators/clickjacking.py4
-rw-r--r--django/views/generic/detail.py4
-rw-r--r--django/views/i18n.py2
39 files changed, 78 insertions, 79 deletions
diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
index 80ba2eebc6..a5704812cf 100644
--- a/django/contrib/admin/filters.py
+++ b/django/contrib/admin/filters.py
@@ -85,7 +85,7 @@ class SimpleListFilter(ListFilter):
query string for this filter, if any. If the value wasn't provided then
returns None.
"""
- return self.used_parameters.get(self.parameter_name, None)
+ return self.used_parameters.get(self.parameter_name)
def lookups(self, request, model_admin):
"""
@@ -220,8 +220,8 @@ class BooleanFieldListFilter(FieldListFilter):
def __init__(self, field, request, params, model, model_admin, field_path):
self.lookup_kwarg = '%s__exact' % field_path
self.lookup_kwarg2 = '%s__isnull' % field_path
- self.lookup_val = request.GET.get(self.lookup_kwarg, None)
- self.lookup_val2 = request.GET.get(self.lookup_kwarg2, None)
+ self.lookup_val = request.GET.get(self.lookup_kwarg)
+ self.lookup_val2 = request.GET.get(self.lookup_kwarg2)
super(BooleanFieldListFilter, self).__init__(field,
request, params, model, model_admin, field_path)
@@ -350,9 +350,8 @@ class AllValuesFieldListFilter(FieldListFilter):
def __init__(self, field, request, params, model, model_admin, field_path):
self.lookup_kwarg = field_path
self.lookup_kwarg_isnull = '%s__isnull' % field_path
- self.lookup_val = request.GET.get(self.lookup_kwarg, None)
- self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull,
- None)
+ self.lookup_val = request.GET.get(self.lookup_kwarg)
+ self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull)
parent_model, reverse_path = reverse_field_path(model, field_path)
# Obey parent ModelAdmin queryset when deciding which options to show
if model == parent_model:
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 5f150aca2b..ece061490f 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -200,7 +200,7 @@ class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)):
ordering. Otherwise don't specify the queryset, let the field decide
(returns None in that case).
"""
- related_admin = self.admin_site._registry.get(db_field.remote_field.model, None)
+ related_admin = self.admin_site._registry.get(db_field.remote_field.model)
if related_admin is not None:
ordering = related_admin.get_ordering(request)
if ordering is not None and ordering != ():
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 84fc757e26..daf46e4a81 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -106,7 +106,7 @@ class UserChangeForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(UserChangeForm, self).__init__(*args, **kwargs)
- f = self.fields.get('user_permissions', None)
+ f = self.fields.get('user_permissions')
if f is not None:
f.queryset = f.queryset.select_related('content_type')
diff --git a/django/contrib/auth/management/commands/createsuperuser.py b/django/contrib/auth/management/commands/createsuperuser.py
index c1251b32d6..7d374b863d 100644
--- a/django/contrib/auth/management/commands/createsuperuser.py
+++ b/django/contrib/auth/management/commands/createsuperuser.py
@@ -50,7 +50,7 @@ class Command(BaseCommand):
return super(Command, self).execute(*args, **options)
def handle(self, *args, **options):
- username = options.get(self.UserModel.USERNAME_FIELD, None)
+ username = options.get(self.UserModel.USERNAME_FIELD)
database = options.get('database')
# If not provided, create the user with an unusable password
diff --git a/django/contrib/flatpages/forms.py b/django/contrib/flatpages/forms.py
index 6e7448c397..b990fa36de 100644
--- a/django/contrib/flatpages/forms.py
+++ b/django/contrib/flatpages/forms.py
@@ -35,8 +35,8 @@ class FlatpageForm(forms.ModelForm):
return url
def clean(self):
- url = self.cleaned_data.get('url', None)
- sites = self.cleaned_data.get('sites', None)
+ url = self.cleaned_data.get('url')
+ sites = self.cleaned_data.get('sites')
same_url = FlatPage.objects.filter(url=url)
if self.instance.pk:
diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py
index c2a46399d2..4fe9969b0d 100644
--- a/django/contrib/gis/db/models/query.py
+++ b/django/contrib/gis/db/models/query.py
@@ -32,7 +32,7 @@ class GeoQuerySet(QuerySet):
# Performing setup here rather than in `_spatial_attribute` so that
# we can get the units for `AreaField`.
procedure_args, geo_field = self._spatial_setup(
- 'area', field_name=kwargs.get('field_name', None))
+ 'area', field_name=kwargs.get('field_name'))
s = {'procedure_args': procedure_args,
'geo_field': geo_field,
'setup': False,
@@ -403,7 +403,7 @@ class GeoQuerySet(QuerySet):
"""
if not isinstance(srid, six.integer_types):
raise TypeError('An integer SRID must be provided.')
- field_name = kwargs.get('field_name', None)
+ field_name = kwargs.get('field_name')
self._spatial_setup('transform', field_name=field_name)
self.query.add_context('transformed_srid', srid)
return self._clone()
@@ -534,7 +534,7 @@ class GeoQuerySet(QuerySet):
if settings.get('setup', True):
default_args, geo_field = self._spatial_setup(
att, desc=settings['desc'], field_name=field_name,
- geo_field_type=settings.get('geo_field_type', None))
+ geo_field_type=settings.get('geo_field_type'))
for k, v in six.iteritems(default_args):
settings['procedure_args'].setdefault(k, v)
else:
@@ -563,7 +563,7 @@ class GeoQuerySet(QuerySet):
fmt = '%%(function)s(%s)' % settings['procedure_fmt']
# If the result of this function needs to be converted.
- if settings.get('select_field', False):
+ if settings.get('select_field'):
select_field = settings['select_field']
if connection.ops.oracle:
select_field.empty_strings_allowed = False
@@ -583,7 +583,7 @@ class GeoQuerySet(QuerySet):
DRY routine for GeoQuerySet distance attribute routines.
"""
# Setting up the distance procedure arguments.
- procedure_args, geo_field = self._spatial_setup(func, field_name=kwargs.get('field_name', None))
+ procedure_args, geo_field = self._spatial_setup(func, field_name=kwargs.get('field_name'))
# If geodetic defaulting distance attribute to meters (Oracle and
# PostGIS spherical distances return meters). Otherwise, use the
diff --git a/django/contrib/gis/feeds.py b/django/contrib/gis/feeds.py
index fc66beec45..555602fa9f 100644
--- a/django/contrib/gis/feeds.py
+++ b/django/contrib/gis/feeds.py
@@ -36,7 +36,7 @@ class GeoFeedMixin(object):
This routine adds a GeoRSS XML element using the given item and handler.
"""
# Getting the Geometry object.
- geom = item.get('geometry', None)
+ geom = item.get('geometry')
if geom is not None:
if isinstance(geom, (list, tuple)):
# Special case if a tuple/list was passed in. The tuple may be
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py
index 0c672e4227..c1e1934886 100644
--- a/django/contrib/gis/gdal/geomtype.py
+++ b/django/contrib/gis/gdal/geomtype.py
@@ -37,7 +37,7 @@ class OGRGeomType(object):
type_input = type_input.lower()
if type_input == 'geometry':
type_input = 'unknown'
- num = self._str_types.get(type_input, None)
+ num = self._str_types.get(type_input)
if num is None:
raise GDALException('Invalid OGR String Type "%s"' % type_input)
elif isinstance(type_input, int):
diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py
index 0b160ffea3..39a651f727 100644
--- a/django/contrib/gis/geoip/base.py
+++ b/django/contrib/gis/geoip/base.py
@@ -89,7 +89,7 @@ class GeoIP(object):
# Getting the GeoIP data path.
if not path:
- path = GEOIP_SETTINGS.get('GEOIP_PATH', None)
+ path = GEOIP_SETTINGS.get('GEOIP_PATH')
if not path:
raise GeoIPException('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
if not isinstance(path, six.string_types):
diff --git a/django/contrib/gis/geoip/libgeoip.py b/django/contrib/gis/geoip/libgeoip.py
index a6023ff229..c5f5d24b82 100644
--- a/django/contrib/gis/geoip/libgeoip.py
+++ b/django/contrib/gis/geoip/libgeoip.py
@@ -8,7 +8,7 @@ from django.conf import settings
GEOIP_SETTINGS = {key: getattr(settings, key)
for key in ('GEOIP_PATH', 'GEOIP_LIBRARY_PATH', 'GEOIP_COUNTRY', 'GEOIP_CITY')
if hasattr(settings, key)}
-lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH', None)
+lib_path = GEOIP_SETTINGS.get('GEOIP_LIBRARY_PATH')
# The shared library for the GeoIP C API. May be downloaded
# from http://www.maxmind.com/download/geoip/api/c/
diff --git a/django/contrib/gis/geos/linestring.py b/django/contrib/gis/geos/linestring.py
index 8e191c4b04..f1c26af72e 100644
--- a/django/contrib/gis/geos/linestring.py
+++ b/django/contrib/gis/geos/linestring.py
@@ -72,7 +72,7 @@ class LineString(ProjectInterpolateMixin, GEOSGeometry):
cs[i] = coords[i]
# If SRID was passed in with the keyword arguments
- srid = kwargs.get('srid', None)
+ srid = kwargs.get('srid')
# Calling the base geometry initialization with the returned pointer
# from the function.
diff --git a/django/contrib/postgres/forms/array.py b/django/contrib/postgres/forms/array.py
index 01c4d53527..1e8b44f975 100644
--- a/django/contrib/postgres/forms/array.py
+++ b/django/contrib/postgres/forms/array.py
@@ -112,7 +112,7 @@ class SplitArrayWidget(forms.Widget):
value = value or []
output = []
final_attrs = self.build_attrs(attrs)
- id_ = final_attrs.get('id', None)
+ id_ = final_attrs.get('id')
for i in range(max(len(value), self.size)):
try:
widget_value = value[i]
diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py
index 38b6112f51..9ee8351930 100644
--- a/django/contrib/sessions/backends/cache.py
+++ b/django/contrib/sessions/backends/cache.py
@@ -20,7 +20,7 @@ class SessionStore(SessionBase):
def load(self):
try:
- session_data = self._cache.get(self.cache_key, None)
+ session_data = self._cache.get(self.cache_key)
except Exception:
# Some backends (e.g. memcache) raise an exception on invalid
# cache keys. If this happens, reset the session. See #17810.
diff --git a/django/contrib/sessions/backends/cached_db.py b/django/contrib/sessions/backends/cached_db.py
index 23e0a74bbf..848913b51e 100644
--- a/django/contrib/sessions/backends/cached_db.py
+++ b/django/contrib/sessions/backends/cached_db.py
@@ -29,7 +29,7 @@ class SessionStore(DBStore):
def load(self):
try:
- data = self._cache.get(self.cache_key, None)
+ data = self._cache.get(self.cache_key)
except Exception:
# Some backends (e.g. memcache) raise an exception on invalid
# cache keys. If this happens, reset the session. See #17810.
diff --git a/django/contrib/sessions/middleware.py b/django/contrib/sessions/middleware.py
index 69ca669033..dc22b6605d 100644
--- a/django/contrib/sessions/middleware.py
+++ b/django/contrib/sessions/middleware.py
@@ -12,7 +12,7 @@ class SessionMiddleware(object):
self.SessionStore = engine.SessionStore
def process_request(self, request):
- session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
+ session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME)
request.session = self.SessionStore(session_key)
def process_response(self, request, response):
diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py
index 930279bf96..0fc646d36a 100644
--- a/django/contrib/sitemaps/__init__.py
+++ b/django/contrib/sitemaps/__init__.py
@@ -112,8 +112,8 @@ class Sitemap(object):
all_items_lastmod = True # track if all items have a lastmod
for item in self.paginator.page(page).object_list:
loc = "%s://%s%s" % (protocol, domain, self.__get('location', item))
- priority = self.__get('priority', item, None)
- lastmod = self.__get('lastmod', item, None)
+ priority = self.__get('priority', item)
+ lastmod = self.__get('lastmod', item)
if all_items_lastmod:
all_items_lastmod = lastmod is not None
if (all_items_lastmod and
@@ -123,7 +123,7 @@ class Sitemap(object):
'item': item,
'location': loc,
'lastmod': lastmod,
- 'changefreq': self.__get('changefreq', item, None),
+ 'changefreq': self.__get('changefreq', item),
'priority': str(priority if priority is not None else ''),
}
urls.append(url_info)
@@ -138,7 +138,7 @@ class GenericSitemap(Sitemap):
def __init__(self, info_dict, priority=None, changefreq=None):
self.queryset = info_dict['queryset']
- self.date_field = info_dict.get('date_field', None)
+ self.date_field = info_dict.get('date_field')
self.priority = priority
self.changefreq = changefreq
diff --git a/django/contrib/staticfiles/finders.py b/django/contrib/staticfiles/finders.py
index 7c775e7f89..81a919bf04 100644
--- a/django/contrib/staticfiles/finders.py
+++ b/django/contrib/staticfiles/finders.py
@@ -168,7 +168,7 @@ class AppDirectoriesFinder(BaseFinder):
"""
Find a requested static file in an app's static locations.
"""
- storage = self.storages.get(app, None)
+ storage = self.storages.get(app)
if storage:
# only try to find a file if the source dir actually exists
if storage.exists(path):
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index 6a0a5407dd..b3c53b7232 100644
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -308,7 +308,7 @@ class ManifestFilesMixin(HashedFilesMixin):
except ValueError:
pass
else:
- version = stored.get('version', None)
+ version = stored.get('version')
if version == '1.0':
return stored.get('paths', OrderedDict())
raise ValueError("Couldn't load manifest '%s' (version %s)" %
@@ -341,7 +341,7 @@ class _MappingCache(object):
self.cache.set(key, value)
def __getitem__(self, key):
- value = self.cache.get(key, None)
+ value = self.cache.get(key)
if value is None:
raise KeyError("Couldn't find a file name '%s'" % key)
return value
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py
index 26113aaa31..0ffd47bc2a 100644
--- a/django/core/cache/backends/base.py
+++ b/django/core/cache/backends/base.py
@@ -74,7 +74,7 @@ class BaseCache(object):
self.key_prefix = params.get('KEY_PREFIX', '')
self.version = params.get('VERSION', 1)
- self.key_func = get_key_func(params.get('KEY_FUNCTION', None))
+ self.key_func = get_key_func(params.get('KEY_FUNCTION'))
def get_backend_timeout(self, timeout=DEFAULT_TIMEOUT):
"""
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index af68885641..fdd12a1e16 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -24,7 +24,7 @@ class BaseMemcachedCache(BaseCache):
self.LibraryValueNotFoundException = value_not_found_exception
self._lib = library
- self._options = params.get('OPTIONS', None)
+ self._options = params.get('OPTIONS')
@property
def _cache(self):
diff --git a/django/core/management/commands/check.py b/django/core/management/commands/check.py
index 818700e4ed..f50d234f8c 100644
--- a/django/core/management/commands/check.py
+++ b/django/core/management/commands/check.py
@@ -32,7 +32,7 @@ class Command(BaseCommand):
else:
app_configs = None
- tags = options.get('tags', None)
+ tags = options.get('tags')
if tags:
try:
invalid_tag = next(
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
index 2fe220b622..4cd36f3c8a 100644
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -43,7 +43,7 @@ class Command(BaseCommand):
self.dry_run = options.get('dry_run', False)
self.merge = options.get('merge', False)
self.empty = options.get('empty', False)
- self.migration_name = options.get('name', None)
+ self.migration_name = options.get('name')
self.exit_code = options.get('exit_code', False)
# Make sure the app they asked for exists
@@ -165,7 +165,7 @@ class Command(BaseCommand):
if not self.dry_run:
# Write the migrations file to the disk.
migrations_directory = os.path.dirname(writer.path)
- if not directory_created.get(app_label, False):
+ if not directory_created.get(app_label):
if not os.path.isdir(migrations_directory):
os.mkdir(migrations_directory)
init_path = os.path.join(migrations_directory, "__init__.py")
diff --git a/django/core/serializers/xml_serializer.py b/django/core/serializers/xml_serializer.py
index 0a301cb946..e8415230d6 100644
--- a/django/core/serializers/xml_serializer.py
+++ b/django/core/serializers/xml_serializer.py
@@ -23,8 +23,8 @@ class Serializer(base.Serializer):
"""
def indent(self, level):
- if self.options.get('indent', None) is not None:
- self.xml.ignorableWhitespace('\n' + ' ' * self.options.get('indent', None) * level)
+ if self.options.get('indent') is not None:
+ self.xml.ignorableWhitespace('\n' + ' ' * self.options.get('indent') * level)
def start_serialization(self):
"""
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index a73985d724..ad6aeda380 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -591,7 +591,7 @@ class MigrationAutodetector(object):
added = set(self.new_proxy_keys) - set(self.old_proxy_keys)
for app_label, model_name in sorted(added):
model_state = self.to_state.models[app_label, model_name]
- assert model_state.options.get("proxy", False)
+ assert model_state.options.get("proxy")
# Depend on the deletion of any possible non-proxy version of us
dependencies = [
(app_label, model_name, None, False),
@@ -695,7 +695,7 @@ class MigrationAutodetector(object):
for name, field in sorted(related_fields.items()):
dependencies.append((app_label, model_name, name, False))
# We're referenced in another field's through=
- through_user = self.through_users.get((app_label, model_state.name_lower), None)
+ through_user = self.through_users.get((app_label, model_state.name_lower))
if through_user:
dependencies.append((through_user[0], through_user[1], through_user[2], False))
# Finally, make the operation, deduping any dependencies
@@ -714,7 +714,7 @@ class MigrationAutodetector(object):
deleted = set(self.old_proxy_keys) - set(self.new_proxy_keys)
for app_label, model_name in sorted(deleted):
model_state = self.from_state.models[app_label, model_name]
- assert model_state.options.get("proxy", False)
+ assert model_state.options.get("proxy")
self.add_operation(
app_label,
operations.DeleteModel(
@@ -980,12 +980,12 @@ class MigrationAutodetector(object):
old_model_name = self.renamed_models.get((app_label, model_name), model_name)
old_model_state = self.from_state.models[app_label, old_model_name]
new_model_state = self.to_state.models[app_label, model_name]
- if (old_model_state.options.get("order_with_respect_to", None) !=
- new_model_state.options.get("order_with_respect_to", None)):
+ if (old_model_state.options.get("order_with_respect_to") !=
+ new_model_state.options.get("order_with_respect_to")):
# Make sure it comes second if we're adding
# (removal dependency is part of RemoveField)
dependencies = []
- if new_model_state.options.get("order_with_respect_to", None):
+ if new_model_state.options.get("order_with_respect_to"):
dependencies.append((
app_label,
model_name,
@@ -997,7 +997,7 @@ class MigrationAutodetector(object):
app_label,
operations.AlterOrderWithRespectTo(
name=model_name,
- order_with_respect_to=new_model_state.options.get('order_with_respect_to', None),
+ order_with_respect_to=new_model_state.options.get('order_with_respect_to'),
),
dependencies=dependencies,
)
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 98594b6127..78e74b7850 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -1739,7 +1739,7 @@ class FilePathField(Field):
kwargs['allow_files'] = self.allow_files
if self.allow_folders is not False:
kwargs['allow_folders'] = self.allow_folders
- if kwargs.get("max_length", None) == 100:
+ if kwargs.get("max_length") == 100:
del kwargs["max_length"]
return name, path, args, kwargs
@@ -1955,7 +1955,7 @@ class GenericIPAddressField(Field):
kwargs['unpack_ipv4'] = self.unpack_ipv4
if self.protocol != "both":
kwargs['protocol'] = self.protocol
- if kwargs.get("max_length", None) == 39:
+ if kwargs.get("max_length") == 39:
del kwargs['max_length']
return name, path, args, kwargs
@@ -2099,7 +2099,7 @@ class SlugField(CharField):
def deconstruct(self):
name, path, args, kwargs = super(SlugField, self).deconstruct()
- if kwargs.get("max_length", None) == 50:
+ if kwargs.get("max_length") == 50:
del kwargs['max_length']
if self.db_index is False:
kwargs['db_index'] = False
@@ -2288,7 +2288,7 @@ class URLField(CharField):
def deconstruct(self):
name, path, args, kwargs = super(URLField, self).deconstruct()
- if kwargs.get("max_length", None) == 200:
+ if kwargs.get("max_length") == 200:
del kwargs['max_length']
return name, path, args, kwargs
diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index 2363088a6e..3f4c7064e4 100644
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -282,7 +282,7 @@ class FileField(Field):
def deconstruct(self):
name, path, args, kwargs = super(FileField, self).deconstruct()
- if kwargs.get("max_length", None) == 100:
+ if kwargs.get("max_length") == 100:
del kwargs["max_length"]
kwargs['upload_to'] = self.upload_to
if self.storage is not default_storage:
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 5f455b12be..050994811a 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1216,7 +1216,7 @@ class RawQuerySet(object):
model_cls = deferred_class_factory(self.model, skip)
else:
model_cls = self.model
- fields = [self.model_fields.get(c, None) for c in self.columns]
+ fields = [self.model_fields.get(c) for c in self.columns]
converters = compiler.get_converters([
f.get_col(f.model._meta.db_table) if f else None for f in fields
])
diff --git a/django/forms/models.py b/django/forms/models.py
index 3c3f1e29ff..c5d1423376 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -378,7 +378,7 @@ class BaseModelForm(BaseForm):
# from validation.
else:
form_field = self.fields[field]
- field_value = self.cleaned_data.get(field, None)
+ field_value = self.cleaned_data.get(field)
if not f.blank and not form_field.required and field_value in form_field.empty_values:
exclude.append(f.name)
return exclude
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 24d2dc87a4..cc82c2ec79 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -50,7 +50,7 @@ class Media(object):
self._js = []
for name in MEDIA_TYPES:
- getattr(self, 'add_' + name)(media_attrs.get(name, None))
+ getattr(self, 'add_' + name)(media_attrs.get(name))
def __str__(self):
return self.render()
@@ -228,7 +228,7 @@ class Widget(six.with_metaclass(MediaDefiningClass)):
Given a dictionary of data and this widget's name, returns the value
of this widget. Returns None if it's not provided.
"""
- return data.get(name, None)
+ return data.get(name)
def id_for_label(self, id_):
"""
@@ -317,7 +317,7 @@ class MultipleHiddenInput(HiddenInput):
if value is None:
value = []
final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
- id_ = final_attrs.get('id', None)
+ id_ = final_attrs.get('id')
inputs = []
for i, v in enumerate(value):
input_attrs = dict(value=force_text(v), **final_attrs)
@@ -331,7 +331,7 @@ class MultipleHiddenInput(HiddenInput):
def value_from_datadict(self, data, files, name):
if isinstance(data, MultiValueDict):
return data.getlist(name)
- return data.get(name, None)
+ return data.get(name)
class FileInput(Input):
@@ -343,7 +343,7 @@ class FileInput(Input):
def value_from_datadict(self, data, files, name):
"File widgets take data from FILES, not POST"
- return files.get(name, None)
+ return files.get(name)
FILE_INPUT_CONTRADICTION = object()
@@ -581,13 +581,13 @@ class NullBooleanSelect(Select):
return super(NullBooleanSelect, self).render(name, value, attrs, choices)
def value_from_datadict(self, data, files, name):
- value = data.get(name, None)
+ value = data.get(name)
return {'2': True,
True: True,
'True': True,
'3': False,
'False': False,
- False: False}.get(value, None)
+ False: False}.get(value)
class SelectMultiple(Select):
@@ -607,7 +607,7 @@ class SelectMultiple(Select):
def value_from_datadict(self, data, files, name):
if isinstance(data, MultiValueDict):
return data.getlist(name)
- return data.get(name, None)
+ return data.get(name)
@html_safe
@@ -706,7 +706,7 @@ class ChoiceFieldRenderer(object):
If an id was given to the field, it is applied to the <ul> (each
item in the list will get an id of `$id_$i`).
"""
- id_ = self.attrs.get('id', None)
+ id_ = self.attrs.get('id')
output = []
for i, choice in enumerate(self.choices):
choice_value, choice_label = choice
@@ -831,7 +831,7 @@ class MultiWidget(Widget):
value = self.decompress(value)
output = []
final_attrs = self.build_attrs(attrs)
- id_ = final_attrs.get('id', None)
+ id_ = final_attrs.get('id')
for i, widget in enumerate(self.widgets):
try:
widget_value = value[i]
@@ -1031,7 +1031,7 @@ class SelectDateWidget(Widget):
return date_value.strftime(input_format)
else:
return '%s-%s-%s' % (y, m, d)
- return data.get(name, None)
+ return data.get(name)
def create_select(self, name, field, value, val, choices, none_value):
if 'id' in self.attrs:
diff --git a/django/http/request.py b/django/http/request.py
index 97592b444a..fbd355eeff 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -172,7 +172,7 @@ class HttpRequest(object):
raise ImproperlyConfigured(
'The SECURE_PROXY_SSL_HEADER setting must be a tuple containing two values.'
)
- if self.META.get(header, None) == value:
+ if self.META.get(header) == value:
return 'https'
return self._get_scheme()
diff --git a/django/middleware/cache.py b/django/middleware/cache.py
index 79202adda3..11a65cd928 100644
--- a/django/middleware/cache.py
+++ b/django/middleware/cache.py
@@ -131,11 +131,11 @@ class FetchFromCacheMiddleware(object):
if cache_key is None:
request._cache_update_cache = True
return None # No cache information available, need to rebuild.
- response = self.cache.get(cache_key, None)
+ response = self.cache.get(cache_key)
# if it wasn't found and we are looking for a HEAD, try looking just for that
if response is None and request.method == 'HEAD':
cache_key = get_cache_key(request, self.key_prefix, 'HEAD', cache=self.cache)
- response = self.cache.get(cache_key, None)
+ response = self.cache.get(cache_key)
if response is None:
request._cache_update_cache = True
diff --git a/django/middleware/clickjacking.py b/django/middleware/clickjacking.py
index d9ee12d8a5..b9aaa035f1 100644
--- a/django/middleware/clickjacking.py
+++ b/django/middleware/clickjacking.py
@@ -28,7 +28,7 @@ class XFrameOptionsMiddleware(object):
"""
def process_response(self, request, response):
# Don't set it if it's already in the response
- if response.get('X-Frame-Options', None) is not None:
+ if response.get('X-Frame-Options') is not None:
return response
# Don't set it if they used @xframe_options_exempt
diff --git a/django/template/base.py b/django/template/base.py
index 3fd02570c2..1b05fe57b8 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -1325,7 +1325,7 @@ class Library(object):
# inclusion tags are often used for forms, and we need
# instructions for using CSRF protection to be as simple
# as possible.
- csrf_token = context.get('csrf_token', None)
+ csrf_token = context.get('csrf_token')
if csrf_token is not None:
new_context['csrf_token'] = csrf_token
return t.render(new_context)
@@ -1421,7 +1421,7 @@ def get_library(library_name):
Subsequent loads eg. {% load somelib %} in the same process will grab
the cached module from libraries.
"""
- lib = libraries.get(library_name, None)
+ lib = libraries.get(library_name)
if not lib:
templatetags_modules = get_templatetags_modules()
tried_modules = []
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index df2de0f2ea..54d0d5d449 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -53,7 +53,7 @@ class CommentNode(Node):
class CsrfTokenNode(Node):
def render(self, context):
- csrf_token = context.get('csrf_token', None)
+ csrf_token = context.get('csrf_token')
if csrf_token:
if csrf_token == 'NOTPROVIDED':
return format_html("")
diff --git a/django/test/client.py b/django/test/client.py
index d845fe76a7..043bf884a1 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -414,7 +414,7 @@ class Client(RequestFactory):
"""
if apps.is_installed('django.contrib.sessions'):
engine = import_module(settings.SESSION_ENGINE)
- cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None)
+ cookie = self.cookies.get(settings.SESSION_COOKIE_NAME)
if cookie:
return engine.SessionStore(cookie.value)
else:
diff --git a/django/utils/cache.py b/django/utils/cache.py
index 66d5e75e40..73d9c3dca5 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -189,7 +189,7 @@ def _generate_cache_key(request, method, headerlist, key_prefix):
"""Returns a cache key from the headers given in the header list."""
ctx = hashlib.md5()
for header in headerlist:
- value = request.META.get(header, None)
+ value = request.META.get(header)
if value is not None:
ctx.update(force_bytes(value))
url = hashlib.md5(force_bytes(iri_to_uri(request.build_absolute_uri())))
@@ -221,7 +221,7 @@ def get_cache_key(request, key_prefix=None, method='GET', cache=None):
cache_key = _generate_cache_header_key(key_prefix, request)
if cache is None:
cache = caches[settings.CACHE_MIDDLEWARE_ALIAS]
- headerlist = cache.get(cache_key, None)
+ headerlist = cache.get(cache_key)
if headerlist is not None:
return _generate_cache_key(request, method, headerlist, key_prefix)
else:
diff --git a/django/views/decorators/clickjacking.py b/django/views/decorators/clickjacking.py
index fcd78871dd..2a0c53d2a4 100644
--- a/django/views/decorators/clickjacking.py
+++ b/django/views/decorators/clickjacking.py
@@ -18,7 +18,7 @@ def xframe_options_deny(view_func):
"""
def wrapped_view(*args, **kwargs):
resp = view_func(*args, **kwargs)
- if resp.get('X-Frame-Options', None) is None:
+ if resp.get('X-Frame-Options') is None:
resp['X-Frame-Options'] = 'DENY'
return resp
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
@@ -39,7 +39,7 @@ def xframe_options_sameorigin(view_func):
"""
def wrapped_view(*args, **kwargs):
resp = view_func(*args, **kwargs)
- if resp.get('X-Frame-Options', None) is None:
+ if resp.get('X-Frame-Options') is None:
resp['X-Frame-Options'] = 'SAMEORIGIN'
return resp
return wraps(view_func, assigned=available_attrs(view_func))(wrapped_view)
diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py
index 8840c1bd7f..9ac54313c1 100644
--- a/django/views/generic/detail.py
+++ b/django/views/generic/detail.py
@@ -32,8 +32,8 @@ class SingleObjectMixin(ContextMixin):
queryset = self.get_queryset()
# Next, try looking up by primary key.
- pk = self.kwargs.get(self.pk_url_kwarg, None)
- slug = self.kwargs.get(self.slug_url_kwarg, None)
+ pk = self.kwargs.get(self.pk_url_kwarg)
+ slug = self.kwargs.get(self.slug_url_kwarg)
if pk is not None:
queryset = queryset.filter(pk=pk)
diff --git a/django/views/i18n.py b/django/views/i18n.py
index 1d6c845e35..49bcfead4d 100644
--- a/django/views/i18n.py
+++ b/django/views/i18n.py
@@ -36,7 +36,7 @@ def set_language(request):
next = '/'
response = http.HttpResponseRedirect(next)
if request.method == 'POST':
- lang_code = request.POST.get('language', None)
+ lang_code = request.POST.get('language')
if lang_code and check_for_language(lang_code):
next_trans = translate_url(next, lang_code)
if next_trans != next: