Skip to content

Commit a54c84d

Browse files
bluenote10JukkaL
authored andcommitted
Bring back type annotation support of dunder methods in stub generator (#12828)
Fixes #12717
1 parent 290f013 commit a54c84d

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/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] = ...
@@ -20,6 +21,7 @@ class Point:
2021
def name(self) -> str: ...
2122

2223
class LengthUnit:
24+
__members__: ClassVar[dict] = ... # read-only
2325
__entries: ClassVar[dict] = ...
2426
inch: ClassVar[Point.LengthUnit] = ...
2527
mm: ClassVar[Point.LengthUnit] = ...

0 commit comments

Comments
 (0)