sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
232 stars 47 forks source link

Ignore private attributes #81

Open StefanBruens opened 2 years ago

StefanBruens commented 2 years ago

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
    ...