Skip to content

Commit f19a711

Browse files
authored
Bring back type annotation support of dunder methods in stub generator (#12828)
Fixes #12717
1 parent 927a9ba commit f19a711

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mypy/stubgenc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def infer_prop_type(docstr: Optional[str]) -> Optional[str]:
288288
return None
289289

290290
# Ignore special properties/attributes.
291-
if name.startswith('__') and name.endswith('__'):
291+
if is_skipped_attribute(name):
292292
return
293293

294294
inferred = infer_prop_type(getattr(obj, '__doc__', None))

test-data/pybind11_mypy_demo/stubgen/pybind11_mypy_demo/basics.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PI: float
55

66
class Point:
77
class AngleUnit:
8+
__members__: ClassVar[dict] = ... # read-only
89
__entries: ClassVar[dict] = ...
910
degree: ClassVar[Point.AngleUnit] = ...
1011
radian: ClassVar[Point.AngleUnit] = ...
@@ -22,6 +23,7 @@ class Point:
2223
def value(self) -> int: ...
2324

2425
class LengthUnit:
26+
__members__: ClassVar[dict] = ... # read-only
2527
__entries: ClassVar[dict] = ...
2628
inch: ClassVar[Point.LengthUnit] = ...
2729
mm: ClassVar[Point.LengthUnit] = ...

0 commit comments

Comments
 (0)