Render @property-@name.setter pattern for rw properties in stubgenc
Open
Nobody has claimed this yet.
feature
topic-descriptors
topic-stubgen
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Currently, stubgen renders the readwrite properties as a plain class field with inferred type. e.g.
in a pybind11 module
cls.def_property("my_property", &MyClass::GetProperty, &MyClass::SetProperty);
will result in
class MyClass:
my_property: int
Could it be possible to render a @property-@name.setter pair instead, like:
class MyClass:
@property
def my_property(self) -> int: ...
@my_property.setter
def my_property(self, val: int) -> None: ...
Pitch
This way can more clearly reflect the fact that it is a property. I'm happy to help create a PR for this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating stubgenc's current handling of readwrite properties and inspect how inferred class fields are emitted. The work is done when the generated stub uses the requested @property and @name.setter pair, with the getter and setter annotations shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100