Skip to content

Commit

Permalink
Fixed E125 pep8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Medrela authored and timgraham committed Nov 28, 2013
1 parent d1df395 commit 7477a4f
Show file tree
Hide file tree
Showing 38 changed files with 67 additions and 67 deletions.
2 changes: 1 addition & 1 deletion django/contrib/admin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def get_changelist_form(self, request, **kwargs):
}
defaults.update(kwargs)
if (defaults.get('fields') is None
and not modelform_defines_fields(defaults.get('form'))):
and not modelform_defines_fields(defaults.get('form'))):
defaults['fields'] = forms.ALL_FIELDS

return modelform_factory(self.model, **defaults)
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admin/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def check_dependencies(self):
raise ImproperlyConfigured("Put 'django.contrib.contenttypes' in "
"your INSTALLED_APPS setting in order to use the admin application.")
if not ('django.contrib.auth.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS or
'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS):
'django.core.context_processors.auth' in settings.TEMPLATE_CONTEXT_PROCESSORS):
raise ImproperlyConfigured("Put 'django.contrib.auth.context_processors.auth' "
"in your TEMPLATE_CONTEXT_PROCESSORS setting in order to use the admin application.")

Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admin/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def validate_prepopulated_fields(self, cls, model):
for field, val in cls.prepopulated_fields.items():
f = get_field(cls, model, 'prepopulated_fields', field)
if isinstance(f, (models.DateTimeField, models.ForeignKey,
models.ManyToManyField)):
models.ManyToManyField)):
raise ImproperlyConfigured("'%s.prepopulated_fields['%s']' "
"is either a DateTimeField, ForeignKey or "
"ManyToManyField. This isn't allowed."
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/auth/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _wrapped_view(request, *args, **kwargs):
login_scheme, login_netloc = urlparse(resolved_login_url)[:2]
current_scheme, current_netloc = urlparse(path)[:2]
if ((not login_scheme or login_scheme == current_scheme) and
(not login_netloc or login_netloc == current_netloc)):
(not login_netloc or login_netloc == current_netloc)):
path = request.get_full_path()
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(
Expand Down
4 changes: 2 additions & 2 deletions django/contrib/flatpages/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def clean_url(self):
code='missing_leading_slash',
)
if (settings.APPEND_SLASH and
'django.middleware.common.CommonMiddleware' in settings.MIDDLEWARE_CLASSES and
not url.endswith('/')):
'django.middleware.common.CommonMiddleware' in settings.MIDDLEWARE_CLASSES and
not url.endswith('/')):
raise forms.ValidationError(
ugettext("URL is missing a trailing slash."),
code='missing_trailing_slash',
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/formtools/wizard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def as_view(cls, *args, **kwargs):

@classmethod
def get_initkwargs(cls, form_list=None, initial_dict=None,
instance_dict=None, condition_dict=None, *args, **kwargs):
instance_dict=None, condition_dict=None, *args, **kwargs):
"""
Creates a dict with all needed parameters for the form wizard instances.
Expand Down
4 changes: 2 additions & 2 deletions django/contrib/gis/db/backends/postgis/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def get_distance(self, f, dist_val, lookup_type):
dist_param = value

if (not geography and geodetic and lookup_type != 'dwithin'
and option == 'spheroid'):
and option == 'spheroid'):
# using distance_spheroid requires the spheroid of the field as
# a parameter.
return [f._spheroid, dist_param]
Expand Down Expand Up @@ -467,7 +467,7 @@ def exactly_two(np):
def two_to_three(np):
return np >= 2 and np <= 3
if (lookup_type in self.distance_functions and
lookup_type != 'dwithin'):
lookup_type != 'dwithin'):
return two_to_three(num_param)
else:
return exactly_two(num_param)
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/db/models/sql/where.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _prepare_data(self, data):
if isinstance(data, (list, tuple)):
obj, lookup_type, value = data
if (isinstance(obj, Constraint) and
isinstance(obj.field, GeometryField)):
isinstance(obj.field, GeometryField)):
data = (GeoConstraint(obj), lookup_type, value)
return super(GeoWhereNode, self)._prepare_data(data)

Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import connection

if (hasattr(connection.ops, 'spatial_version') and
not connection.ops.mysql):
not connection.ops.mysql):
# Getting the `SpatialRefSys` and `GeometryColumns`
# models for the default spatial backend. These
# aliases are provided for backwards-compatibility.
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/utils/layermapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def verify_ogr_field(self, ogr_field, model_field):
otherwise the proper exception is raised.
"""
if (isinstance(ogr_field, OFTString) and
isinstance(model_field, (models.CharField, models.TextField))):
isinstance(model_field, (models.CharField, models.TextField))):
if self.encoding:
# The encoding for OGR data sources may be specified here
# (e.g., 'cp437' for Census Bureau boundary files).
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/sessions/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_clear(self):

def test_save(self):
if (hasattr(self.session, '_cache') and 'DummyCache' in
settings.CACHES[settings.SESSION_CACHE_ALIAS]['BACKEND']):
settings.CACHES[settings.SESSION_CACHE_ALIAS]['BACKEND']):
raise unittest.SkipTest("Session saving tests require a real cache backend")
self.session.save()
self.assertTrue(self.session.exists(self.session.session_key))
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/sitemaps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_urls(self, page=1, site=None, protocol=None):
if all_items_lastmod:
all_items_lastmod = lastmod is not None
if (all_items_lastmod and
(latest_lastmod is None or lastmod > latest_lastmod)):
(latest_lastmod is None or lastmod > latest_lastmod)):
latest_lastmod = lastmod
url_info = {
'item': item,
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def cursor(self):
"""
self.validate_thread_sharing()
if (self.use_debug_cursor or
(self.use_debug_cursor is None and settings.DEBUG)):
(self.use_debug_cursor is None and settings.DEBUG)):
cursor = self.make_debug_cursor(self._cursor())
else:
cursor = utils.CursorWrapper(self._cursor(), self)
Expand Down
2 changes: 1 addition & 1 deletion django/db/backends/mysql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def resolve_columns(self, row, fields=()):
index_extra_select = len(self.query.extra_select)
for value, field in zip_longest(row[index_extra_select:], fields):
if (field and field.get_internal_type() in ("BooleanField", "NullBooleanField") and
value in (0, 1)):
value in (0, 1)):
value = bool(value)
values.append(value)
return row[:index_extra_select] + tuple(values)
Expand Down
4 changes: 2 additions & 2 deletions django/db/models/deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def can_fast_delete(self, objs, from_field=None):
# Foreign keys pointing to this model, both from m2m and other
# models.
for related in opts.get_all_related_objects(
include_hidden=True, include_proxy_eq=True):
include_hidden=True, include_proxy_eq=True):
if related.field.rel.on_delete is not DO_NOTHING:
return False
# GFK deletes
Expand All @@ -145,7 +145,7 @@ def can_fast_delete(self, objs, from_field=None):
return True

def collect(self, objs, source=None, nullable=False, collect_related=True,
source_attr=None, reverse_dependency=False):
source_attr=None, reverse_dependency=False):
"""
Adds 'objs' to the collection of objects to be deleted as well as all
parent instances. 'objs' must be a homogenous iterable collection of
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ def get_prep_value(self, value):

def get_prep_lookup(self, lookup_type, value):
if ((lookup_type == 'gte' or lookup_type == 'lt')
and isinstance(value, float)):
and isinstance(value, float)):
value = math.ceil(value)
return super(IntegerField, self).get_prep_lookup(lookup_type, value)

Expand Down
4 changes: 2 additions & 2 deletions django/db/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def bulk_create(self, objs, batch_size=None):
fields = self.model._meta.local_fields
with transaction.commit_on_success_unless_managed(using=self.db):
if (connection.features.can_combine_inserts_with_and_without_auto_increment_pk
and self.model._meta.has_auto_field):
and self.model._meta.has_auto_field):
self._batched_insert(objs, fields, batch_size)
else:
objs_with_pk, objs_without_pk = partition(lambda o: o.pk is None, objs)
Expand Down Expand Up @@ -1494,7 +1494,7 @@ class RawQuerySet(object):
annotated model instances.
"""
def __init__(self, raw_query, model=None, query=None, params=None,
translations=None, using=None, hints=None):
translations=None, using=None, hints=None):
self.raw_query = raw_query
self.model = model
self._db = using
Expand Down
8 changes: 4 additions & 4 deletions django/db/models/sql/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,9 @@ def add_aggregate(self, aggregate, model, alias, is_summary):
raise FieldError("Cannot compute %s('%s'): '%s' is an aggregate" % (
aggregate.name, field_name, field_name))
elif ((len(field_list) > 1) or
(field_list[0] not in [i.name for i in opts.fields]) or
self.group_by is None or
not is_summary):
(field_list[0] not in [i.name for i in opts.fields]) or
self.group_by is None or
not is_summary):
# If:
# - the field descriptor has more than one part (foo__bar), or
# - the field descriptor is referencing an m2m/m2o field, or
Expand Down Expand Up @@ -1906,7 +1906,7 @@ def is_nullable(self, field):
# is_nullable() is needed to the compiler stage, but that is not easy
# to do currently.
if ((connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls)
and field.empty_strings_allowed):
and field.empty_strings_allowed):
return True
else:
return field.null
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/sql/subqueries.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def delete_qs(self, query, using):
innerq_used_tables = [t for t in innerq.tables
if innerq.alias_refcount[t]]
if ((not innerq_used_tables or innerq_used_tables == self.tables)
and not len(innerq.having)):
and not len(innerq.having)):
# There is only the base table in use in the query, and there is
# no aggregate filtering going on.
self.where = innerq.where
Expand Down
4 changes: 2 additions & 2 deletions django/db/models/sql/where.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _prepare_data(self, data):
# and empty values need special handling. Other types could be used
# here in the future (using Python types is suggested for consistency).
if (isinstance(value, datetime.datetime)
or (isinstance(obj.field, DateTimeField) and lookup_type != 'isnull')):
or (isinstance(obj.field, DateTimeField) and lookup_type != 'isnull')):
value_annotation = datetime.datetime
elif hasattr(value, 'value_annotation'):
value_annotation = value.value_annotation
Expand Down Expand Up @@ -207,7 +207,7 @@ def make_atom(self, child, qn, connection):
params = field_params + params

if (len(params) == 1 and params[0] == '' and lookup_type == 'exact'
and connection.features.interprets_empty_strings_as_nulls):
and connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value_annotation = True

Expand Down
4 changes: 2 additions & 2 deletions django/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,8 @@ def __init__(self, path, match=None, recursive=False, allow_files=True,
continue
full_file = os.path.join(self.path, f)
if (((self.allow_files and os.path.isfile(full_file)) or
(self.allow_folders and os.path.isdir(full_file))) and
(self.match is None or self.match_re.search(f))):
(self.allow_folders and os.path.isdir(full_file))) and
(self.match is None or self.match_re.search(f))):
self.choices.append((full_file, f))
except OSError:
pass
Expand Down
6 changes: 3 additions & 3 deletions django/forms/formsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ def full_clean(self):
self._errors.append(form.errors)
try:
if (self.validate_max and
self.total_form_count() - len(self.deleted_forms) > self.max_num) or \
self.management_form.cleaned_data[TOTAL_FORM_COUNT] > self.absolute_max:
self.total_form_count() - len(self.deleted_forms) > self.max_num) or \
self.management_form.cleaned_data[TOTAL_FORM_COUNT] > self.absolute_max:
raise ValidationError(ungettext(
"Please submit %d or fewer forms.",
"Please submit %d or fewer forms.", self.max_num) % self.max_num,
code='too_many_forms',
)
if (self.validate_min and
self.total_form_count() - len(self.deleted_forms) < self.min_num):
self.total_form_count() - len(self.deleted_forms) < self.min_num):
raise ValidationError(ungettext(
"Please submit %d or more forms.",
"Please submit %d or more forms.", self.min_num) % self.min_num,
Expand Down
6 changes: 3 additions & 3 deletions django/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
# be difficult to debug for code that needs updating, so we produce the
# warning here too.
if (getattr(Meta, 'fields', None) is None and
getattr(Meta, 'exclude', None) is None):
getattr(Meta, 'exclude', None) is None):
warnings.warn("Calling modelform_factory without defining 'fields' or "
"'exclude' explicitly is deprecated",
DeprecationWarning, stacklevel=2)
Expand Down Expand Up @@ -675,7 +675,7 @@ def validate_unique(self):
for form in valid_forms:
# see if we have data for both fields
if (form.cleaned_data and form.cleaned_data[field] is not None
and form.cleaned_data[unique_for] is not None):
and form.cleaned_data[unique_for] is not None):
# if it's a date lookup we need to get the data for all the fields
if lookup == 'date':
date = form.cleaned_data[unique_for]
Expand Down Expand Up @@ -815,7 +815,7 @@ def modelformset_factory(model, form=ModelForm, formfield_callback=None,
if meta is None:
meta = type(str('Meta'), (object,), {})
if (getattr(meta, 'fields', fields) is None and
getattr(meta, 'exclude', exclude) is None):
getattr(meta, 'exclude', exclude) is None):
warnings.warn("Calling modelformset_factory without defining 'fields' or "
"'exclude' explicitly is deprecated",
DeprecationWarning, stacklevel=2)
Expand Down
2 changes: 1 addition & 1 deletion django/http/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_host(self):
"""Returns the HTTP host using the environment or request headers."""
# We try three options, in order of decreasing preference.
if settings.USE_X_FORWARDED_HOST and (
'HTTP_X_FORWARDED_HOST' in self.META):
'HTTP_X_FORWARDED_HOST' in self.META):
host = self.META['HTTP_X_FORWARDED_HOST']
elif 'HTTP_HOST' in self.META:
host = self.META['HTTP_HOST']
Expand Down
2 changes: 1 addition & 1 deletion django/middleware/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def process_response(self, request, response):
etag = '"%s"' % hashlib.md5(response.content).hexdigest()
if etag is not None:
if (200 <= response.status_code < 300
and request.META.get('HTTP_IF_NONE_MATCH') == etag):
and request.META.get('HTTP_IF_NONE_MATCH') == etag):
cookies = response.cookies
response = http.HttpResponseNotModified()
response.cookies = cookies
Expand Down
2 changes: 1 addition & 1 deletion django/template/defaultfilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _dec(*args, **kwargs):
args = list(args)
args[0] = force_text(args[0])
if (isinstance(args[0], SafeData) and
getattr(_dec._decorated_function, 'is_safe', False)):
getattr(_dec._decorated_function, 'is_safe', False)):
return mark_safe(func(*args, **kwargs))
return func(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion django/template/loader_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def render(self, context):
def super(self):
render_context = self.context.render_context
if (BLOCK_CONTEXT_KEY in render_context and
render_context[BLOCK_CONTEXT_KEY].get_block(self.name) is not None):
render_context[BLOCK_CONTEXT_KEY].get_block(self.name) is not None):
return mark_safe(self.render(self.context))
return ''

Expand Down
2 changes: 1 addition & 1 deletion django/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def setup_databases(verbosity, interactive, **kwargs):
mirrors = []

for signature, (db_name, aliases) in dependency_ordered(
test_databases.items(), dependencies):
test_databases.items(), dependencies):
test_db_name = None
# Actually create the database for the first connection
for alias in aliases:
Expand Down
8 changes: 4 additions & 4 deletions django/test/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _assert_contains(self, response, text, status_code, msg_prefix, html):
# If the response supports deferred rendering and hasn't been rendered
# yet, then ensure that it does get rendered before proceeding further.
if (hasattr(response, 'render') and callable(response.render)
and not response.is_rendered):
and not response.is_rendered):
response.render()

if msg_prefix:
Expand Down Expand Up @@ -1043,7 +1043,7 @@ def run(self):
(self.host, port), QuietWSGIRequestHandler)
except socket.error as e:
if (index + 1 < len(self.possible_ports) and
e.errno == errno.EADDRINUSE):
e.errno == errno.EADDRINUSE):
# This port is already in use, so we go on and try with
# the next one in the list.
continue
Expand Down Expand Up @@ -1097,7 +1097,7 @@ def setUpClass(cls):
# If using in-memory sqlite databases, pass the connections to
# the server thread.
if (conn.vendor == 'sqlite'
and conn.settings_dict['NAME'] == ':memory:'):
and conn.settings_dict['NAME'] == ':memory:'):
# Explicitly enable thread-shareability for this connection
conn.allow_thread_sharing = True
connections_override[conn.alias] = conn
Expand Down Expand Up @@ -1154,7 +1154,7 @@ def _tearDownClassInternal(cls):
# Restore sqlite connections' non-sharability
for conn in connections.all():
if (conn.vendor == 'sqlite'
and conn.settings_dict['NAME'] == ':memory:'):
and conn.settings_dict['NAME'] == ':memory:'):
conn.allow_thread_sharing = False

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions django/utils/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def safe_join(base, *paths):
# b) The final path must be the same as the base path.
# c) The base path must be the most root path (meaning either "/" or "C:\\")
if (not normcase(final_path).startswith(normcase(base_path + sep)) and
normcase(final_path) != normcase(base_path) and
dirname(normcase(base_path)) != normcase(base_path)):
normcase(final_path) != normcase(base_path) and
dirname(normcase(base_path)) != normcase(base_path)):
raise ValueError('The joined path (%s) is located outside of the base '
'path component (%s)' % (final_path, base_path))
return final_path
Expand Down
Loading

0 comments on commit 7477a4f

Please sign in to comment.