Skip to content

Commit

Permalink
Bring back type annotation support of dunder methods in stub generator (
Browse files Browse the repository at this point in the history
#12828)

Fixes #12717
  • Loading branch information
bluenote10 authored and JukkaL committed May 23, 2022
1 parent 290f013 commit a54c84d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/stubgenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions test-data/stubgen/pybind11_mypy_demo/basics.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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] = ...
Expand All @@ -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] = ...
Expand Down

0 comments on commit a54c84d

Please sign in to comment.