eric6/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py

changeset 8236
695777f04b25
parent 8222
5994b80b8760
child 8244
ed8cb108b27b
equal deleted inserted replaced
8235:78e6d29eb773 8236:695777f04b25
224 224
225 class FunctionVisitor(ast.NodeVisitor): 225 class FunctionVisitor(ast.NodeVisitor):
226 """ 226 """
227 Class implementing a node visitor to check function annotations. 227 Class implementing a node visitor to check function annotations.
228 228
229 Note: this class is modelled after flake8-annotations checker. 229 Note: this class is modeled after flake8-annotations checker.
230 """ 230 """
231 def __init__(self, sourceLines): 231 def __init__(self, sourceLines):
232 """ 232 """
233 Constructor 233 Constructor
234 234
425 @return annotation complexity 425 @return annotation complexity
426 @rtype = int 426 @rtype = int
427 """ 427 """
428 if AstUtilities.isString(annotationNode): 428 if AstUtilities.isString(annotationNode):
429 annotationNode = ast.parse(annotationNode.s).body[0].value 429 annotationNode = ast.parse(annotationNode.s).body[0].value
430 if isinstance(annotationNode, ast.Subscript):
431 return 1 + getAnnotationComplexity(annotationNode.slice.value)
432 if isinstance(annotationNode, ast.Tuple): 430 if isinstance(annotationNode, ast.Tuple):
433 return max(getAnnotationComplexity(n) for n in annotationNode.elts) 431 return max(getAnnotationComplexity(n) for n in annotationNode.elts)
434 return 1 432 return 1

eric ide

mercurial