def check_function_type_comment(self, node): type_comment = getattr(node, 'type_comment', None) if not type_comment: return None try: type_comment_ast = parse_function_type_comment(type_comment) except SyntaxError: # Invalid type comment, just skip it. return None returns = None argtypes = [self.visit(elem, node) for elem in (type_comment_ast.argtypes or [])] if type_comment_ast.returns: returns = self.visit(type_comment_ast.returns, node) return returns, argtypes