"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pylint/checkers/format.py" between
pylint-2.13.7.tar.gz and pylint-2.13.8.tar.gz

About: pylint analyzes Python source code looking for bugs and signs of poor quality.

format.py  (pylint-2.13.7):format.py  (pylint-2.13.8)
skipping to change at line 337 skipping to change at line 337
Args: Args:
tokens: list of Tokens; the entire list of Tokens. tokens: list of Tokens; the entire list of Tokens.
start: int; the position of the keyword in the token list. start: int; the position of the keyword in the token list.
""" """
# If the next token is not a paren, we're fine. # If the next token is not a paren, we're fine.
if self._bracket_stack[-1] == ":" and tokens[start].string == "for": if self._bracket_stack[-1] == ":" and tokens[start].string == "for":
self._bracket_stack.pop() self._bracket_stack.pop()
if tokens[start + 1].string != "(": if tokens[start + 1].string != "(":
return return
if (
tokens[start].string == "not"
and start > 0
and tokens[start - 1].string == "is"
):
# If this is part of an `is not` expression, we have a binary operat
or
# so the parentheses are not necessarily redundant.
return
found_and_or = False found_and_or = False
contains_walrus_operator = False contains_walrus_operator = False
walrus_operator_depth = 0 walrus_operator_depth = 0
contains_double_parens = 0 contains_double_parens = 0
depth = 0 depth = 0
keyword_token = str(tokens[start].string) keyword_token = str(tokens[start].string)
line_num = tokens[start].start[0] line_num = tokens[start].start[0]
for i in range(start, len(tokens) - 1): for i in range(start, len(tokens) - 1):
token = tokens[i] token = tokens[i]
skipping to change at line 410 skipping to change at line 418
# quit early without error. # quit early without error.
elif token[1] == "yield": elif token[1] == "yield":
return return
# A generator expression always has a 'for' token in it, and # A generator expression always has a 'for' token in it, and
# the 'for' token is only legal inside parens when it is in a # the 'for' token is only legal inside parens when it is in a
# generator expression. The parens are necessary here, so bail # generator expression. The parens are necessary here, so bail
# without an error. # without an error.
elif token[1] == "for": elif token[1] == "for":
return return
# A generator expression can have an 'else' token in it. # A generator expression can have an 'else' token in it.
# We check the rest of the tokens to see if any problems incur a fter # We check the rest of the tokens to see if any problems occur a fter
# the 'else'. # the 'else'.
elif token[1] == "else": elif token[1] == "else":
if "(" in (i.string for i in tokens[i:]): if "(" in (i.string for i in tokens[i:]):
self._check_keyword_parentheses(tokens[i:], 0) self._check_keyword_parentheses(tokens[i:], 0)
return return
def _prepare_token_dispatcher(self): def _prepare_token_dispatcher(self):
dispatch = {} dispatch = {}
for tokens, handler in ((_KEYWORD_TOKENS, self._check_keyword_parenthese s),): for tokens, handler in ((_KEYWORD_TOKENS, self._check_keyword_parenthese s),):
for token in tokens: for token in tokens:
 End of changes. 2 change blocks. 
1 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)