diff -r bd9550caf22f -r 2bd590c40309 src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py --- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py Thu Dec 08 16:03:38 2022 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py Thu Dec 08 18:03:42 2022 +0100 @@ -20,7 +20,7 @@ from .ast_unparse import unparse ############################################################################### -## The following code is derived from the flake8-simplify package (v0.19.2). +## The following code is derived from the flake8-simplify package (v0.19.3). ## ## Original License: ## @@ -557,10 +557,19 @@ or not isinstance(node.body[0].value.value, ast.Name) or node.target.id != node.body[0].value.value.id or node.orelse != [] - or isinstance(node.parent, ast.AsyncFunctionDef) ): - iterable = unparse(node.iter) - self.__error(node.lineno - 1, node.col_offset, "Y104", iterable) + parent = getattr(node, "parent", None) + while ( + parent + and hasattr(parent, "parent") + and parent.parent is not parent + and not isinstance(parent, ast.AsyncFunctionDef) + ): + parent = getattr(parent, "parent", None) + + if not isinstance(parent, ast.AsyncFunctionDef): + iterable = unparse(node.iter) + self.__error(node.lineno - 1, node.col_offset, "Y104", iterable) def __check105(self, node): """