32 ## Return Annotations |
32 ## Return Annotations |
33 "A201", "A202", "A203", "A204", "A205", "A206", |
33 "A201", "A202", "A203", "A204", "A205", "A206", |
34 |
34 |
35 ## Mixed kind of annotations |
35 ## Mixed kind of annotations |
36 "A301", |
36 "A301", |
|
37 |
|
38 ## Annotations Future |
|
39 "A871", |
37 |
40 |
38 ## Annotation Coverage |
41 ## Annotation Coverage |
39 "A881", |
42 "A881", |
40 |
43 |
41 ## Annotation Complexity |
44 ## Annotation Complexity |
84 self.__checkFunctionAnnotations, |
87 self.__checkFunctionAnnotations, |
85 ("A001", "A002", "A003", "A101", "A102", |
88 ("A001", "A002", "A003", "A101", "A102", |
86 "A201", "A202", "A203", "A204", "A205", "A206", |
89 "A201", "A202", "A203", "A204", "A205", "A206", |
87 "A301", ) |
90 "A301", ) |
88 ), |
91 ), |
|
92 (self.__checkAnnotationsFuture, ("A871",)), |
89 (self.__checkAnnotationsCoverage, ("A881",)), |
93 (self.__checkAnnotationsCoverage, ("A881",)), |
90 (self.__checkAnnotationComplexity, ("A891", "A892")), |
94 (self.__checkAnnotationComplexity, ("A891", "A892")), |
91 ] |
95 ] |
92 |
96 |
93 self.__checkers = [] |
97 self.__checkers = [] |
161 check() |
165 check() |
162 |
166 |
163 ####################################################################### |
167 ####################################################################### |
164 ## Annotations |
168 ## Annotations |
165 ## |
169 ## |
166 ## adapted from: flake8-annotations v2.6.2 |
170 ## adapted from: flake8-annotations v2.7.0 |
167 ####################################################################### |
171 ####################################################################### |
168 |
172 |
169 def __checkFunctionAnnotations(self): |
173 def __checkFunctionAnnotations(self): |
170 """ |
174 """ |
171 Private method to check for function annotation issues. |
175 Private method to check for function annotation issues. |
543 else: |
547 else: |
544 return len(annotationNode.slice.value.elts) |
548 return len(annotationNode.slice.value.elts) |
545 except AttributeError: |
549 except AttributeError: |
546 return 0 |
550 return 0 |
547 return 0 |
551 return 0 |
|
552 |
|
553 ####################################################################### |
|
554 ## 'from __future__ import annotations' checck |
|
555 ## |
|
556 ## adapted from: flake8-future-annotations v0.0.4 |
|
557 ####################################################################### |
|
558 |
|
559 def __checkAnnotationsFuture(self): |
|
560 """ |
|
561 Private method to check the use of __future__ and typing imports. |
|
562 """ |
|
563 from .AnnotationsFutureVisitor import AnnotationsFutureVisitor |
|
564 visitor = AnnotationsFutureVisitor() |
|
565 visitor.visit(self.__tree) |
|
566 |
|
567 if ( |
|
568 visitor.importsFutureAnnotations() or |
|
569 not visitor.hasTypingImports() |
|
570 ): |
|
571 return |
|
572 |
|
573 imports = ", ".join(visitor.getTypingImports()) |
|
574 self.__error(0, 0, "A871", imports) |