mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Merge pull request #1848 from rayashmanjr/master
Correct flake8 violation E261
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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',)) | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user