--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Sun Feb 23 12:42:47 2025 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Mon Feb 24 15:11:18 2025 +0100 @@ -27,36 +27,36 @@ Codes = [ ## Function Annotations - "A001", - "A002", - "A003", + "A-001", + "A-002", + "A-003", ## Method Annotations - "A101", - "A102", + "A-101", + "A-102", ## Return Annotations - "A201", - "A202", - "A203", - "A204", - "A205", - "A206", + "A-201", + "A-202", + "A-203", + "A-204", + "A-205", + "A-206", ## Dynamically typed annotations - "A401", + "A-401", ## Type comments - "A402", + "A-402", ## Annotations Future - "A871", - "A872", - "A873", + "A-871", + "A-872", + "A-873", ## Annotation Coverage - "A881", + "A-881", ## Annotation Complexity - "A891", - "A892", + "A-891", + "A-892", ## use of typing.Union (PEP 604) - "A901", + "A-901", ## deprecated 'typing' symbols (PEP 585) - "A911", + "A-911", ] def __init__(self, source, filename, tree, select, ignore, expected, repeat, args): @@ -99,26 +99,26 @@ ( self.__checkFunctionAnnotations, ( - "A001", - "A002", - "A003", - "A101", - "A102", - "A201", - "A202", - "A203", - "A204", - "A205", - "A206", - "A401", - "A402", + "A-001", + "A-002", + "A-003", + "A-101", + "A-102", + "A-201", + "A-202", + "A-203", + "A-204", + "A-205", + "A-206", + "A-401", + "A-402", ), ), - (self.__checkAnnotationsFuture, ("A871", "A872", "A873")), - (self.__checkAnnotationsCoverage, ("A881",)), - (self.__checkAnnotationComplexity, ("A891", "A892")), - (self.__checkAnnotationPep604, ("A901",)), - (self.__checkDeprecatedTypingSymbols, ("A911",)), + (self.__checkAnnotationsFuture, ("A-871", "A-872", "A-873")), + (self.__checkAnnotationsCoverage, ("A-881",)), + (self.__checkAnnotationComplexity, ("A-891", "A-892")), + (self.__checkAnnotationPep604, ("A-901",)), + (self.__checkDeprecatedTypingSymbols, ("A-911",)), ] self.__checkers = [] @@ -259,7 +259,7 @@ # Iterate over the arguments with missing type hints, by function. for function in visitor.functionDefinitions: if function.hasTypeComment: - self.__error(function.lineno - 1, function.col_offset, "A402") + self.__error(function.lineno - 1, function.col_offset, "A-402") if function.isDynamicallyTyped() and ( allowUntypedDefs or (function.isNested and allowUntypedNested) @@ -284,7 +284,7 @@ }: continue - self.__error(function.lineno - 1, function.col_offset, "A401") + self.__error(function.lineno - 1, function.col_offset, "A-401") # Before we iterate over the function's missing annotations, check # to see if it's the closing function def in a series of @@ -317,7 +317,7 @@ # Check for type comments here since we're not considering them as # typed args if arg.hasTypeComment: - self.__error(arg.lineno - 1, arg.col_offset, "A402") + self.__error(arg.lineno - 1, arg.col_offset, "A-402") if arg.argname == "return": # return annotations have multiple possible short-circuit @@ -383,7 +383,7 @@ arg.annotationType, ) - if errorCode in ("A001", "A002", "A003"): + if errorCode in ("A-001", "A-002", "A-003"): self.__error(arg.lineno - 1, arg.col_offset, errorCode, arg.argname) else: self.__error(arg.lineno - 1, arg.col_offset, errorCode) @@ -406,18 +406,18 @@ # priority than the rest if isClassMethod: if classDecoratorType == ClassDecoratorType.CLASSMETHOD: - return "A206" + return "A-206" elif classDecoratorType == ClassDecoratorType.STATICMETHOD: - return "A205" + return "A-205" if functionType == FunctionType.SPECIAL: - return "A204" + return "A-204" elif functionType == FunctionType.PRIVATE: - return "A203" + return "A-203" elif functionType == FunctionType.PROTECTED: - return "A202" + return "A-202" else: - return "A201" + return "A-201" @lru_cache() # __IGNORE_WARNING_M519__ def __argumentErrorClassifier( @@ -443,19 +443,19 @@ # The first function argument here would be an instance of self or # class if classDecoratorType == ClassDecoratorType.CLASSMETHOD: - return "A102" + return "A-102" elif classDecoratorType != ClassDecoratorType.STATICMETHOD: # Regular class method - return "A101" + return "A-101" # Check for remaining codes if annotationType == AnnotationType.KWARG: - return "A003" + return "A-003" elif annotationType == AnnotationType.VARARG: - return "A002" + return "A-002" else: # Combine PosOnlyArgs, Args, and KwOnlyArgs - return "A001" + return "A-001" ####################################################################### ## Annotations Coverage @@ -495,7 +495,7 @@ * 100 ) if annotationsCoverage < minAnnotationsCoverage: - self.__error(0, 0, "A881", annotationsCoverage) + self.__error(0, 0, "A-881", annotationsCoverage) def __hasTypeAnnotations(self, funcNode): """ @@ -568,7 +568,7 @@ self.__error( annotation.lineno - 1, annotation.col_offset, - "A891", + "A-891", complexity, maxAnnotationComplexity, ) @@ -578,7 +578,7 @@ self.__error( annotation.lineno - 1, annotation.col_offset, - "A892", + "A-892", annotationLength, maxAnnotationLength, ) @@ -680,13 +680,13 @@ if visitor.hasTypingImports(): imports = ", ".join(visitor.getTypingImports()) - self.__error(0, 0, "A871", imports) + self.__error(0, 0, "A-871", imports) elif forceFutureAnnotations: - self.__error(0, 0, "A872") + self.__error(0, 0, "A-872") if checkFutureAnnotations and visitor.hasSimplifiedTypes(): simplifiedTypes = ", ".join(sorted(visitor.getSimplifiedTypes())) - self.__error(0, 0, "A873", simplifiedTypes) + self.__error(0, 0, "A-873", simplifiedTypes) ####################################################################### ## check use of 'typing.Union' (see PEP 604) @@ -708,7 +708,7 @@ visitor.visit(self.__tree) for node in visitor.getIssues(): - self.__error(node.lineno - 1, node.col_offset, "A901") + self.__error(node.lineno - 1, node.col_offset, "A-901") ####################################################################### ## check use of 'typing.Union' (see PEP 604) @@ -741,4 +741,4 @@ visitor.visit(self.__tree) for node, (name, replacement) in visitor.getIssues(): - self.__error(node.lineno - 1, node.col_offset, "A911", name, replacement) + self.__error(node.lineno - 1, node.col_offset, "A-911", name, replacement)