Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correct flake8 violation E261

  • Loading branch information...
commit dcfc8fa9721955dc4fcfb6e5e506be12f74c5b85 1 parent b44d42b
Ray Ashman Jr authored
View
6 django/forms/fields.py
@@ -45,9 +45,9 @@
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 = {
View
8 django/forms/forms.py
@@ -120,7 +120,7 @@ def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
# 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 @@ def add_initial_prefix(self, field_name):
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 @@ def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_
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 @@ def full_clean(self):
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
View
4 django/forms/formsets.py
@@ -244,7 +244,7 @@ def ordered_forms(self):
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 @@ def full_clean(self):
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]
View
8 django/forms/widgets.py
@@ -161,8 +161,8 @@ def __str__(self):
return self.parent_widget.render(*args)
class Widget(six.with_metaclass(MediaDefiningClass)):
- is_hidden = False # Determines whether this corresponds to an <input type="hidden">.
- needs_multipart_form = False # Determines does this widget need multipart form
+ is_hidden = False # Determines whether this corresponds to an <input type="hidden">.
+ 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 <input> 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 @@ def __init__(self, name, value, attrs, choices):
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):
View
10 django/template/base.py
@@ -246,9 +246,9 @@ def parse(self, parse_until=None):
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 @@ def parse(self, parse_until=None):
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 @@ def _resolve_lookup(self, context):
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
View
26 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
View
6 django/template/defaulttags.py
@@ -347,7 +347,7 @@ def render(self, context):
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 @@ def render(self, context):
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
View
4 django/template/loader_tags.py
@@ -93,7 +93,7 @@ def get_parent(self, context):
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',))
View
8 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 @@ def __init__(self, tokens):
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
View
2  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)
View
2  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)
View
2  django/utils/checksums.py
@@ -6,7 +6,7 @@
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):
"""
View
2  django/utils/dateformat.py
@@ -267,7 +267,7 @@ def r(self):
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:
View
4 django/utils/dates.py
@@ -27,7 +27,7 @@
'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 @@
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'),
View
8 django/utils/dictconfig.py
@@ -210,7 +210,7 @@ def cfg_convert(self, value):
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 @@ def convert(self, value):
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 @@ def configure(self):
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 @@ def configure(self):
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:
View
4 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))
View
12 django/utils/html_parser.py
@@ -84,22 +84,22 @@ def parse_starttag(self, i):
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()
View
2  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:

0 comments on commit dcfc8fa

Please sign in to comment.
Something went wrong with that request. Please try again.