--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py Mon Feb 17 16:28:25 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Simplify/SimplifyNodeVisitor.py Mon Feb 17 17:09:25 2025 +0100 @@ -24,29 +24,7 @@ ############################################################################### ## adapted from: flake8-simplify v0.21.0 ## -## Original License: -## -## MIT License -## -## Copyright (c) 2020 Martin Thoma -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to -## deal in the Software without restriction, including without limitation the -## rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -## sell copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included in -## all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -## IN THE SOFTWARE. +## combined with: flake8-nested-fstring v1.1.0 ############################################################################### @@ -254,6 +232,17 @@ self.generic_visit(node) + def visit_JoinedStr(self, node): + """ + Public method to check a joined string node. + + @param node reference to the node to be processed + @type ast.JoinedStr + """ + self.__check411(node) + + self.generic_visit(node) + ############################################################# ## Helper methods for the various checkers below ############################################################# @@ -1711,6 +1700,23 @@ if hasBareNumeric and not isException: self.__error(node.lineno - 1, node.col_offset, "Y402") + def __check411(self, node): + """ + Private method to check for nested f-strings. + + Note: This method is adapted from flake8-nested-fstrings v1.1.0. + + @param node reference to the AST node to be checked + @type ast.JoinedStr or ast.expr + """ + for fieldName, value in ast.iter_fields(node): + if fieldName == "values": + for innerNode in value: + self.__check411(innerNode) + + if fieldName == "value" and isinstance(value, ast.JoinedStr): + self.__error(node.lineno - 1, node.col_offset, "Y411") + def __check901(self, node): """ Private method to check for unnecessary bool conversion.