python / python/mypy

stubgen (stubgenc): Support for tp_getset style C properties

Open
#10,492 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-stubgen
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at mypy.stubgenc.is_c_property and inspect how stubgen recognizes properties and reads their docstrings. Determine how tp_getset-style C attributes differ from the existing case, then verify that their docstrings can be used to infer property types without affecting other C-extension attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.