stubgen (stubgenc): Support for tp_getset style C properties

未关闭
#10,492 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
c, python
领域
tooling

调研方向

从 mypy.stubgenc.is_c_property 开始,检查 stubgen 如何识别属性以及读取它们的 docstrings。确定 tp_getset 风格的 C 属性与现有情况有何不同,然后验证是否可以使用它们的 docstrings 推断属性类型,同时不影响其他 C 扩展属性。

由索引模型根据 Issue 内容生成。

描述

feature topic-stubgen

Feature

Currently for C extensions, attributes of a C type originating from tp_getset are not recognized as a class property.
It would be nice to still parse the docstring in such cases, to infer types.

Pitch

As far as I understand, this is due to mypy.stubgenc.is_c_property looking for the fget attribute (the tp_getset style attributes dont have such an attribute - at least in my case, python 3.8).

I am not sure how to properly add checks for such a case (is just removing the check hasattr(obj, 'fget') enough?)

Would be glad for any input here (Am I missing something? Is there a good strategy to add support for tp_getset style attributes?). I would offer to implement the feature, if you think this would make sense.

主要语言
Python
星标
20.6k
派生
3.3k
平均合并
1 天 18 小时
30 天内合并 PR
54

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python/mypy 的其他 Issue

查看 python/mypy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。