pybind11-stubgen icon indicating copy to clipboard operation
pybind11-stubgen copied to clipboard

Ignore private attributes

Open StefanBruens opened this issue 2 years ago • 0 comments

Attributes with a single leading underscore are considered private, not type info should be generated (by default).

Also see https://mypy.readthedocs.io/en/stable/stubgen.html#cmdoption-stubgen-include-private

The following fragment in AttributeStubsGenerator.to_lines seems to do the job:

def to_lines(self):  # type: () -> List[str]
    if re.match(r"^_[^_](.*[^_])?$", self.name):
        pass
    ...

StefanBruens avatar Aug 06 '22 00:08 StefanBruens