diff --git a/django/forms/fields.py b/django/forms/fields.py
index bd62a57200..c95930a2d0 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -45,9 +45,9 @@ __all__ = (
class Field(object):
- widget = TextInput # Default widget to use when rendering this type of Field.
- hidden_widget = HiddenInput # Default widget to use when rendering this as "hidden".
- default_validators = [] # Default set of validators
+ widget = TextInput # Default widget to use when rendering this type of Field.
+ hidden_widget = HiddenInput # Default widget to use when rendering this as "hidden".
+ default_validators = [] # Default set of validators
# Add an 'invalid' entry to default_error_message if you want a specific
# field error message not raised by the field validators.
default_error_messages = {
diff --git a/django/forms/forms.py b/django/forms/forms.py
index d9be2cd3f8..ddd51ffaae 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -120,7 +120,7 @@ class BaseForm(object):
# Translators: This is the default suffix added to form field labels
self.label_suffix = label_suffix if label_suffix is not None else _(':')
self.empty_permitted = empty_permitted
- self._errors = None # Stores the errors after clean() has been called.
+ self._errors = None # Stores the errors after clean() has been called.
self._changed_data = None
# The base_fields class attribute is the *class-wide* definition of
@@ -176,7 +176,7 @@ class BaseForm(object):
def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
"Helper function for outputting HTML. Used by as_table(), as_ul(), as_p()."
- top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
+ top_errors = self.non_field_errors() # Errors that should be displayed above all fields.
output, hidden_fields = [], []
for name, field in self.fields.items():
@@ -223,7 +223,7 @@ class BaseForm(object):
if top_errors:
output.insert(0, error_row % force_text(top_errors))
- if hidden_fields: # Insert any hidden fields in the last row.
+ if hidden_fields: # Insert any hidden fields in the last row.
str_hidden = ''.join(hidden_fields)
if output:
last_row = output[-1]
@@ -295,7 +295,7 @@ class BaseForm(object):
self.cleaned_data.
"""
self._errors = ErrorDict()
- if not self.is_bound: # Stop further processing.
+ if not self.is_bound: # Stop further processing.
return
self.cleaned_data = {}
# If the form is permitted to be empty, and none of the form data has
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index 81e2e8781a..5b2efee82e 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -244,7 +244,7 @@ class BaseFormSet(object):
def compare_ordering_key(k):
if k[1] is None:
- return (1, 0) # +infinity, larger than any number
+ return (1, 0) # +infinity, larger than any number
return (0, k[1])
self._ordering.sort(key=compare_ordering_key)
# Return a list of form.cleaned_data dicts in the order specified by
@@ -316,7 +316,7 @@ class BaseFormSet(object):
self._errors = []
self._non_form_errors = self.error_class()
- if not self.is_bound: # Stop further processing.
+ if not self.is_bound: # Stop further processing.
return
for i in range(0, self.total_form_count()):
form = self.forms[i]
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index a3f69d86ae..55ccada4a1 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -161,8 +161,8 @@ class SubWidget(object):
return self.parent_widget.render(*args)
class Widget(six.with_metaclass(MediaDefiningClass)):
- is_hidden = False # Determines whether this corresponds to an .
- needs_multipart_form = False # Determines does this widget need multipart form
+ is_hidden = False # Determines whether this corresponds to an .
+ needs_multipart_form = False # Determines does this widget need multipart form
is_localized = False
is_required = False
@@ -227,7 +227,7 @@ class Input(Widget):
Base class for all widgets (except type='checkbox' and
type='radio', which are special).
"""
- input_type = None # Subclasses must define this.
+ input_type = None # Subclasses must define this.
def _format_value(self, value):
if self.is_localized:
@@ -643,7 +643,7 @@ class ChoiceFieldRenderer(object):
self.choices = choices
def __getitem__(self, idx):
- choice = self.choices[idx] # Let the IndexError propogate
+ choice = self.choices[idx] # Let the IndexError propogate
return self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, idx)
def __str__(self):
diff --git a/django/template/base.py b/django/template/base.py
index 2979f2a8f1..5f6cac1c6f 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -246,9 +246,9 @@ class Parser(object):
while self.tokens:
token = self.next_token()
# Use the raw values here for TOKEN_* for a tiny performance boost.
- if token.token_type == 0: # TOKEN_TEXT
+ if token.token_type == 0: # TOKEN_TEXT
self.extend_nodelist(nodelist, TextNode(token.contents), token)
- elif token.token_type == 1: # TOKEN_VAR
+ elif token.token_type == 1: # TOKEN_VAR
if not token.contents:
self.empty_variable(token)
try:
@@ -258,7 +258,7 @@ class Parser(object):
raise
var_node = self.create_variable_node(filter_expression)
self.extend_nodelist(nodelist, var_node, token)
- elif token.token_type == 2: # TOKEN_BLOCK
+ elif token.token_type == 2: # TOKEN_BLOCK
try:
command = token.contents.split()[0]
except IndexError:
@@ -772,12 +772,12 @@ class Variable(object):
elif getattr(current, 'alters_data', False):
current = settings.TEMPLATE_STRING_IF_INVALID
else:
- try: # method call (assuming no args required)
+ try: # method call (assuming no args required)
current = current()
except TypeError:
try:
getcallargs(current)
- except TypeError: # arguments *were* required
+ except TypeError: # arguments *were* required
current = settings.TEMPLATE_STRING_IF_INVALID # invalid method call
else:
raise
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 6e424fc6cb..bb3c9b320f 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -261,8 +261,8 @@ def truncatechars(value, arg):
"""
try:
length = int(arg)
- except ValueError: # Invalid literal for int().
- return value # Fail silently.
+ except ValueError: # Invalid literal for int().
+ return value # Fail silently.
return Truncator(value).chars(length)
@register.filter(is_safe=True)
@@ -277,8 +277,8 @@ def truncatewords(value, arg):
"""
try:
length = int(arg)
- except ValueError: # Invalid literal for int().
- return value # Fail silently.
+ except ValueError: # Invalid literal for int().
+ return value # Fail silently.
return Truncator(value).words(length, truncate=' ...')
@register.filter(is_safe=True)
@@ -293,8 +293,8 @@ def truncatewords_html(value, arg):
"""
try:
length = int(arg)
- except ValueError: # invalid literal for int()
- return value # Fail silently.
+ except ValueError: # invalid literal for int()
+ return value # Fail silently.
return Truncator(value).words(length, html=True, truncate=' ...')
@register.filter(is_safe=False)
@@ -511,7 +511,7 @@ def join(value, arg, autoescape=None):
value = [conditional_escape(v) for v in value]
try:
data = conditional_escape(arg).join(value)
- except AttributeError: # fail silently but nicely
+ except AttributeError: # fail silently but nicely
return value
return mark_safe(data)
@@ -563,7 +563,7 @@ def slice_filter(value, arg):
return value[slice(*bits)]
except (ValueError, TypeError):
- return value # Fail silently.
+ return value # Fail silently.
@register.filter(is_safe=True, needs_autoescape=True)
def unordered_list(value, autoescape=None):
@@ -681,7 +681,7 @@ def get_digit(value, arg):
arg = int(arg)
value = int(value)
except ValueError:
- return value # Fail silently for an invalid argument
+ return value # Fail silently for an invalid argument
if arg < 1:
return value
try:
@@ -786,7 +786,7 @@ def yesno(value, arg=None):
arg = ugettext('yes,no,maybe')
bits = arg.split(',')
if len(bits) < 2:
- return value # Invalid arg.
+ return value # Invalid arg.
try:
yes, no, maybe = bits
except ValueError:
@@ -871,13 +871,13 @@ def pluralize(value, arg='s'):
try:
if int(value) != 1:
return plural_suffix
- except ValueError: # Invalid string that's not a number.
+ except ValueError: # Invalid string that's not a number.
pass
- except TypeError: # Value isn't a string or a number; maybe it's a list?
+ except TypeError: # Value isn't a string or a number; maybe it's a list?
try:
if len(value) != 1:
return plural_suffix
- except TypeError: # len() of unsized object.
+ except TypeError: # len() of unsized object.
pass
return singular_suffix
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index bc9cfc1c8f..2822c3d362 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -347,7 +347,7 @@ class SsiNode(Node):
if settings.DEBUG:
return "[Didn't have permission to include file]"
else:
- return '' # Fail silently for invalid includes.
+ return '' # Fail silently for invalid includes.
try:
with open(filepath, 'r') as fp:
output = fp.read()
@@ -361,7 +361,7 @@ class SsiNode(Node):
if settings.DEBUG:
return "[Included template had syntax error: %s]" % e
else:
- return '' # Fail silently for invalid included templates.
+ return '' # Fail silently for invalid included templates.
return output
class LoadNode(Node):
@@ -860,7 +860,7 @@ def ifnotequal(parser, token):
class TemplateLiteral(Literal):
def __init__(self, value, text):
self.value = value
- self.text = text # for better error messages
+ self.text = text # for better error messages
def display(self):
return self.text
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index 28b948174f..c6bb3acadf 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -93,7 +93,7 @@ class ExtendsNode(Node):
self.parent_name.token
raise TemplateSyntaxError(error_msg)
if hasattr(parent, 'render'):
- return parent # parent is a Template object
+ return parent # parent is a Template object
return get_template(parent)
def render(self, context):
@@ -165,7 +165,7 @@ def do_block(parser, token):
if block_name in parser.__loaded_blocks:
raise TemplateSyntaxError("'%s' tag with name '%s' appears more than once" % (bits[0], block_name))
parser.__loaded_blocks.append(block_name)
- except AttributeError: # parser.__loaded_blocks isn't a list yet
+ except AttributeError: # parser.__loaded_blocks isn't a list yet
parser.__loaded_blocks = [block_name]
nodelist = parser.parse(('endblock',))
diff --git a/django/template/smartif.py b/django/template/smartif.py
index e2ca3959a2..7cf1c6a023 100644
--- a/django/template/smartif.py
+++ b/django/template/smartif.py
@@ -13,9 +13,9 @@ class TokenBase(object):
Base class for operators and literals, mainly for debugging and for throwing
syntax errors.
"""
- id = None # node/token type name
- value = None # used by literals
- first = second = None # used by tree nodes
+ id = None # node/token type name
+ value = None # used by literals
+ first = second = None # used by tree nodes
def nud(self, parser):
# Null denotation - called in prefix context
@@ -159,7 +159,7 @@ class IfParser(object):
token = tokens[i]
if token == "not" and i + 1 < l and tokens[i+1] == "in":
token = "not in"
- i += 1 # skip 'in'
+ i += 1 # skip 'in'
mapped_tokens.append(self.translate_token(token))
i += 1
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index 70fe508284..fed2fd84b8 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -257,7 +257,7 @@ def reloader_thread():
fn = code_changed
while RUN_RELOADER:
if fn():
- sys.exit(3) # force reload
+ sys.exit(3) # force reload
time.sleep(1)
diff --git a/django/utils/cache.py b/django/utils/cache.py
index f74056cafa..0d664afdf4 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -112,7 +112,7 @@ def patch_response_headers(response, cache_timeout=None):
if cache_timeout is None:
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
if cache_timeout < 0:
- cache_timeout = 0 # Can't have max-age negative
+ cache_timeout = 0 # Can't have max-age negative
if settings.USE_ETAGS and not response.has_header('ETag'):
if hasattr(response, 'render') and callable(response.render):
response.add_post_render_callback(_set_response_etag)
diff --git a/django/utils/checksums.py b/django/utils/checksums.py
index 7bd21c95e0..1113f3b796 100644
--- a/django/utils/checksums.py
+++ b/django/utils/checksums.py
@@ -6,7 +6,7 @@ __all__ = ['luhn']
from django.utils import six
-LUHN_ODD_LOOKUP = (0, 2, 4, 6, 8, 1, 3, 5, 7, 9) # sum_of_digits(index * 2)
+LUHN_ODD_LOOKUP = (0, 2, 4, 6, 8, 1, 3, 5, 7, 9) # sum_of_digits(index * 2)
def luhn(candidate):
"""
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
index 2fe6760a88..27413a2e67 100644
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -267,7 +267,7 @@ class DateFormat(TimeFormat):
def S(self):
"English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'"
- if self.data.day in (11, 12, 13): # Special case
+ if self.data.day in (11, 12, 13): # Special case
return 'th'
last = self.data.day % 10
if last == 1:
diff --git a/django/utils/dates.py b/django/utils/dates.py
index 37746294b8..25f092e618 100644
--- a/django/utils/dates.py
+++ b/django/utils/dates.py
@@ -27,7 +27,7 @@ MONTHS_3_REV = {
'jan': 1, 'feb': 2, 'mar': 3, 'apr': 4, 'may': 5, 'jun': 6, 'jul': 7, 'aug': 8,
'sep': 9, 'oct': 10, 'nov': 11, 'dec': 12
}
-MONTHS_AP = { # month names in Associated Press style
+MONTHS_AP = { # month names in Associated Press style
1: pgettext_lazy('abbrev. month', 'Jan.'),
2: pgettext_lazy('abbrev. month', 'Feb.'),
3: pgettext_lazy('abbrev. month', 'March'),
@@ -41,7 +41,7 @@ MONTHS_AP = { # month names in Associated Press style
11: pgettext_lazy('abbrev. month', 'Nov.'),
12: pgettext_lazy('abbrev. month', 'Dec.')
}
-MONTHS_ALT = { # required for long date representation by some locales
+MONTHS_ALT = { # required for long date representation by some locales
1: pgettext_lazy('alt. month', 'January'),
2: pgettext_lazy('alt. month', 'February'),
3: pgettext_lazy('alt. month', 'March'),
diff --git a/django/utils/dictconfig.py b/django/utils/dictconfig.py
index c676035dc7..d01b785001 100644
--- a/django/utils/dictconfig.py
+++ b/django/utils/dictconfig.py
@@ -210,7 +210,7 @@ class BaseConfigurator(object):
d = d[idx]
else:
try:
- n = int(idx) # try as number first (most likely)
+ n = int(idx) # try as number first (most likely)
d = d[n]
except TypeError:
d = d[idx]
@@ -238,7 +238,7 @@ class BaseConfigurator(object):
isinstance(value, tuple):
value = ConvertingTuple(value)
value.configurator = self
- elif isinstance(value, six.string_types): # str for py3k
+ elif isinstance(value, six.string_types): # str for py3k
m = self.CONVERT_PATTERN.match(value)
if m:
d = m.groupdict()
@@ -385,7 +385,7 @@ class DictConfigurator(BaseConfigurator):
prefixed = name + "."
pflen = len(prefixed)
num_existing = len(existing)
- i = i + 1 # look at the entry after name
+ i = i + 1 # look at the entry after name
while (i < num_existing) and\
(existing[i][:pflen] == prefixed):
child_loggers.append(existing[i])
@@ -425,7 +425,7 @@ class DictConfigurator(BaseConfigurator):
def configure_formatter(self, config):
"""Configure a formatter from a dictionary."""
if '()' in config:
- factory = config['()'] # for use in exception handler
+ factory = config['()'] # for use in exception handler
try:
result = self.configure_custom(config)
except TypeError as te:
diff --git a/django/utils/html.py b/django/utils/html.py
index 81b06efeef..5b2416f03f 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -175,8 +175,8 @@ def smart_urlquote(url):
try:
scheme, netloc, path, query, fragment = urlsplit(url)
try:
- netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
- except UnicodeError: # invalid domain part
+ netloc = netloc.encode('idna').decode('ascii') # IDN -> ACE
+ except UnicodeError: # invalid domain part
pass
else:
url = urlunsplit((scheme, netloc, path, query, fragment))
diff --git a/django/utils/html_parser.py b/django/utils/html_parser.py
index 2a408e9f55..fe71172cfd 100644
--- a/django/utils/html_parser.py
+++ b/django/utils/html_parser.py
@@ -84,22 +84,22 @@ else:
else:
self.handle_starttag(tag, attrs)
if tag in self.CDATA_CONTENT_ELEMENTS:
- self.set_cdata_mode(tag) # <--------------------------- Changed
+ self.set_cdata_mode(tag) # <--------------------------- Changed
return endpos
# Internal -- parse endtag, return end or -1 if incomplete
def parse_endtag(self, i):
rawdata = self.rawdata
assert rawdata[i:i + 2] == "", "unexpected call to parse_endtag"
- match = _html_parser.endendtag.search(rawdata, i + 1) # >
+ match = _html_parser.endendtag.search(rawdata, i + 1) # >
if not match:
return -1
j = match.end()
- match = _html_parser.endtagfind.match(rawdata, i) # + tag + >
+ match = _html_parser.endtagfind.match(rawdata, i) # + tag + >
if not match:
- if self.cdata_tag is not None: # *** add ***
- self.handle_data(rawdata[i:j]) # *** add ***
- return j # *** add ***
+ if self.cdata_tag is not None: # *** add ***
+ self.handle_data(rawdata[i:j]) # *** add ***
+ return j # *** add ***
self.error("bad end tag: %r" % (rawdata[i:j],))
# --- changed start ---------------------------------------------------
tag = match.group(1).strip()
diff --git a/django/utils/http.py b/django/utils/http.py
index 897b1456c4..413ac72a08 100644
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -211,7 +211,7 @@ def urlsafe_base64_decode(s):
Decodes a base64 encoded string, adding back any trailing equal signs that
might have been stripped.
"""
- s = s.encode('utf-8') # base64encode should only return ASCII.
+ s = s.encode('utf-8') # base64encode should only return ASCII.
try:
return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))
except (LookupError, BinasciiError) as e: