src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py

branch
eric7
changeset 10043
f1427d95cfde
parent 9653
e67609152c5e
child 10046
35b27af462ef
equal deleted inserted replaced
10042:ca636e8d80fd 10043:f1427d95cfde
183 check() 183 check()
184 184
185 ####################################################################### 185 #######################################################################
186 ## Annotations 186 ## Annotations
187 ## 187 ##
188 ## adapted from: flake8-annotations v2.9.0 188 ## adapted from: flake8-annotations v2.9.1
189 ####################################################################### 189 #######################################################################
190 190
191 def __checkFunctionAnnotations(self): 191 def __checkFunctionAnnotations(self):
192 """ 192 """
193 Private method to check for function annotation issues. 193 Private method to check for function annotation issues.
630 return annotationLength 630 return annotationLength
631 631
632 ####################################################################### 632 #######################################################################
633 ## 'from __future__ import annotations' checck 633 ## 'from __future__ import annotations' checck
634 ## 634 ##
635 ## adapted from: flake8-future-annotations v0.0.5 635 ## adapted from: flake8-future-annotations v1.1.0
636 ####################################################################### 636 #######################################################################
637 637
638 def __checkAnnotationsFuture(self): 638 def __checkAnnotationsFuture(self):
639 """ 639 """
640 Private method to check the use of __future__ and typing imports. 640 Private method to check the use of __future__ and typing imports.
642 from .AnnotationsFutureVisitor import AnnotationsFutureVisitor 642 from .AnnotationsFutureVisitor import AnnotationsFutureVisitor
643 643
644 forceFutureAnnotations = self.__args.get( 644 forceFutureAnnotations = self.__args.get(
645 "ForceFutureAnnotations", 645 "ForceFutureAnnotations",
646 AnnotationsCheckerDefaultArgs["ForceFutureAnnotations"], 646 AnnotationsCheckerDefaultArgs["ForceFutureAnnotations"],
647 )
648 checkFutureAnnotations = self.__args.get(
649 "CheckFutureAnnotations",
650 AnnotationsCheckerDefaultArgs["CheckFutureAnnotations"],
647 ) 651 )
648 652
649 visitor = AnnotationsFutureVisitor() 653 visitor = AnnotationsFutureVisitor()
650 visitor.visit(self.__tree) 654 visitor.visit(self.__tree)
651 655
655 if visitor.hasTypingImports(): 659 if visitor.hasTypingImports():
656 imports = ", ".join(visitor.getTypingImports()) 660 imports = ", ".join(visitor.getTypingImports())
657 self.__error(0, 0, "A871", imports) 661 self.__error(0, 0, "A871", imports)
658 elif forceFutureAnnotations: 662 elif forceFutureAnnotations:
659 self.__error(0, 0, "A872") 663 self.__error(0, 0, "A872")
664
665 if checkFutureAnnotations and visitor.hasSimplifiedTypes():
666 simplifiedTypes = ", ".join(sorted(visitor.getSimplifiedTypes()))
667 self.__error(0, 0, "A873", simplifiedTypes)

eric ide

mercurial