diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index 682ed418ffc7..9f90c7aafe69 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -288,7 +288,7 @@ def infer_prop_type(docstr: Optional[str]) -> Optional[str]: return None # Ignore special properties/attributes. - if name.startswith('__') and name.endswith('__'): + if is_skipped_attribute(name): return inferred = infer_prop_type(getattr(obj, '__doc__', None)) diff --git a/test-data/stubgen/pybind11_mypy_demo/basics.pyi b/test-data/stubgen/pybind11_mypy_demo/basics.pyi index 99093fd6087a..d75d7e86a667 100644 --- a/test-data/stubgen/pybind11_mypy_demo/basics.pyi +++ b/test-data/stubgen/pybind11_mypy_demo/basics.pyi @@ -5,6 +5,7 @@ PI: float class Point: class AngleUnit: + __members__: ClassVar[dict] = ... # read-only __entries: ClassVar[dict] = ... degree: ClassVar[Point.AngleUnit] = ... radian: ClassVar[Point.AngleUnit] = ... @@ -20,6 +21,7 @@ class Point: def name(self) -> str: ... class LengthUnit: + __members__: ClassVar[dict] = ... # read-only __entries: ClassVar[dict] = ... inch: ClassVar[Point.LengthUnit] = ... mm: ClassVar[Point.LengthUnit] = ...