src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py

branch
eric7
changeset 9595
2bd590c40309
parent 9278
36448ca469c2
child 9653
e67609152c5e
equal deleted inserted replaced
9594:bd9550caf22f 9595:2bd590c40309
18 except ImportError: 18 except ImportError:
19 # Python < 3.9 19 # Python < 3.9
20 from .ast_unparse import unparse 20 from .ast_unparse import unparse
21 21
22 ############################################################################### 22 ###############################################################################
23 ## The following code is derived from the flake8-simplify package (v0.19.2). 23 ## The following code is derived from the flake8-simplify package (v0.19.3).
24 ## 24 ##
25 ## Original License: 25 ## Original License:
26 ## 26 ##
27 ## MIT License 27 ## MIT License
28 ## 28 ##
555 or not isinstance(node.body[0].value, ast.Yield) 555 or not isinstance(node.body[0].value, ast.Yield)
556 or not isinstance(node.target, ast.Name) 556 or not isinstance(node.target, ast.Name)
557 or not isinstance(node.body[0].value.value, ast.Name) 557 or not isinstance(node.body[0].value.value, ast.Name)
558 or node.target.id != node.body[0].value.value.id 558 or node.target.id != node.body[0].value.value.id
559 or node.orelse != [] 559 or node.orelse != []
560 or isinstance(node.parent, ast.AsyncFunctionDef) 560 ):
561 ): 561 parent = getattr(node, "parent", None)
562 iterable = unparse(node.iter) 562 while (
563 self.__error(node.lineno - 1, node.col_offset, "Y104", iterable) 563 parent
564 and hasattr(parent, "parent")
565 and parent.parent is not parent
566 and not isinstance(parent, ast.AsyncFunctionDef)
567 ):
568 parent = getattr(parent, "parent", None)
569
570 if not isinstance(parent, ast.AsyncFunctionDef):
571 iterable = unparse(node.iter)
572 self.__error(node.lineno - 1, node.col_offset, "Y104", iterable)
564 573
565 def __check105(self, node): 574 def __check105(self, node):
566 """ 575 """
567 Private method to check for "try-except-pass" patterns. 576 Private method to check for "try-except-pass" patterns.
568 577

eric ide

mercurial