Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f19a711

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

File tree

Expand file treeCollapse file tree

2 files changed

+3
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-1
lines changed

‎mypy/stubgenc.py

Copy file name to clipboardExpand all lines: mypy/stubgenc.py
+1-1Lines changed: 1 addition & 1 deletion
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

Copy file name to clipboardExpand all lines: test-data/pybind11_mypy_demo/stubgen/pybind11_mypy_demo/basics.pyi
+2Lines changed: 2 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.