client_parser¶
Parse mypy_boto3_${aws_service}/client.pyi stub file to extract all client methods
Note
这个模块中的所有 *Parser 类都使用了 Command Pattern, 也就是虽然是一个类,
但是它被用来当成一个函数来使用, 主函数只有 .parse() 这一个. 在整个生命周期内,
把需要共享的数据作为属性放在 _attr_name 的属性中, 使得代码更加简洁清晰.
- class boto3_dataclass.parsers.client_parser.ClientModuleParser(path_stub_file: Path)[source]¶
从
mypy_boto3_${aws_service}/client.pyistub file 中解析出所有 client 方法, 提取出返回 TypedDict 的方法, 为生成 dataclass 转换器做准备.- parse_client_class(node_cd: ClassDef)[source]¶
解析 client 类定义, 提取所有返回 TypedDict 的方法.
- Parameters:
node_cd – client 类的 AST ClassDef 节点
- is_client_method_node(node) bool[source]¶
判断给定的 AST 节点是否是我们关心的 client 方法.
我们只关心返回类型是 TypedDict (以 ‘TypeDef’ 结尾) 的方法.
- parse_client_method(node: FunctionDef) CasterMethod[source]¶
解析 client 方法定义, 提取方法名和返回类型信息.
- Parameters:
node – 方法的 AST FunctionDef 节点
- Returns:
解析后的 CasterMethod 对象