--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/LoggingVisitor.py Sat Feb 15 18:32:54 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Logging/LoggingVisitor.py Sun Feb 16 10:54:18 2025 +0100 @@ -301,12 +301,9 @@ for key, keyNode in extraKeys: if key in _LogrecordAttributes: - if isinstance(keyNode, ast.keyword): - lineno, colOffset = self.__keywordPos(keyNode) - else: - lineno = keyNode.lineno - colOffset = keyNode.col_offset - self.__error(lineno - 1, colOffset, "L103", repr(key)) + self.__error( + keyNode.lineno - 1, keyNode.col_offset, "L103", repr(key) + ) if node.func.attr == "exception": # L104 @@ -322,16 +319,14 @@ and isinstance(excInfo.value, ast.Name) and excInfo.value.id == excHandler.name ): - lineno, colOffset = self.__keywordPos(excInfo) - self.__error(lineno - 1, colOffset, "L106") + self.__error(excInfo.lineno - 1, excInfo.col_offset, "L106") # L107 elif ( isinstance(excInfo.value, ast.Constant) and not excInfo.value.value ): - lineno, colOffset = self.__keywordPos(excInfo) - self.__error(lineno - 1, colOffset, "L107") + self.__error(excInfo.lineno - 1, excInfo.col_offset, "L107") # L105 elif node.func.attr == "error" and excHandler is not None: @@ -357,8 +352,7 @@ and isinstance(excInfo.value, ast.Constant) and excInfo.value.value ): - lineno, colOffset = self.__keywordPos(excInfo) - self.__error(lineno - 1, colOffset, "L114") + self.__error(excInfo.lineno - 1, excInfo.col_offset, "L114") # L110 if ( @@ -510,24 +504,6 @@ return None - def __keywordPos(self, node): - """ - Private method determine line number and column offset of a given keyword node. - - @param node reference to the keyword node - @type ast.keyword - @return tuple containing the line number and the column offset - @rtype tuple of (int, int) - """ - if sys.version_info >= (3, 9): - return (node.lineno, node.col_offset) - else: - # Educated guess - return ( - node.value.lineno, - max(0, node.value.col_offset - 1 - len(node.arg)), - ) - def __isAddChainWithNonStr(self, node): """ Private method to check, if the node is an Add with a non string argument.