Skip to content

Render @property-@name.setter pattern for rw properties in stubgenc #15315

Open
@d4n1elchen

Description

@d4n1elchen

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions