--- a/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Tue Nov 16 18:00:40 2021 +0100 +++ b/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Thu Nov 18 19:37:14 2021 +0100 @@ -35,6 +35,9 @@ ## Mixed kind of annotations "A301", + ## Annotations Future + "A871", + ## Annotation Coverage "A881", @@ -86,6 +89,7 @@ "A201", "A202", "A203", "A204", "A205", "A206", "A301", ) ), + (self.__checkAnnotationsFuture, ("A871",)), (self.__checkAnnotationsCoverage, ("A881",)), (self.__checkAnnotationComplexity, ("A891", "A892")), ] @@ -163,7 +167,7 @@ ####################################################################### ## Annotations ## - ## adapted from: flake8-annotations v2.6.2 + ## adapted from: flake8-annotations v2.7.0 ####################################################################### def __checkFunctionAnnotations(self): @@ -545,3 +549,26 @@ except AttributeError: return 0 return 0 + + ####################################################################### + ## 'from __future__ import annotations' checck + ## + ## adapted from: flake8-future-annotations v0.0.4 + ####################################################################### + + def __checkAnnotationsFuture(self): + """ + Private method to check the use of __future__ and typing imports. + """ + from .AnnotationsFutureVisitor import AnnotationsFutureVisitor + visitor = AnnotationsFutureVisitor() + visitor.visit(self.__tree) + + if ( + visitor.importsFutureAnnotations() or + not visitor.hasTypingImports() + ): + return + + imports = ", ".join(visitor.getTypingImports()) + self.__error(0, 0, "A871", imports)