首页 > 解决方案 > Python (ast module): id field of func: expr unknown

问题描述

Using ast module in python, there is a report on call_node.func.id saying that

Type of "id" is unknown (PylancereportUnknownMemberType)

Cannot access member "id" for type "expr" Member "id" is unknown (PylancereportGeneralTypeIssues)

call_node is a Call class in the module.

def check_inner_recursion(self):
    for call_node in self.funccall:
        if (self.func_def.name == call_node.func.id):
            return True

I have tried looking at the fields of call_node.func and these are the outputs

('id', 'ctx')

The purpose of this is to get the function name of the call. Is there any work around to the error?

标签: python-3.xabstract-syntax-treetype-hintingpylance

解决方案


推荐阅读