Skip to content

Commit 787d5b6

Browse files
committed
Update tests
1 parent b229f27 commit 787d5b6

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

mypy/stubgenc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,8 @@ def generate_class_stub(
876876
bases_str = ""
877877

878878
if class_info.docstring and self._include_docstrings:
879-
doc = f" {self._indent}{quote_docstring(class_info.docstring)}"
879+
doc = quote_docstring(self._indent_docstring(class_info.docstring))
880+
doc = f" {self._indent}{doc}"
880881
docstring = doc.splitlines(keepends=False)
881882
else:
882883
docstring = []

test-data/pybind11_fixtures/expected_stubs_with_docs/pybind11_fixtures/__init__.pyi

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ class TestStruct:
3838
def __init__(self, *args, **kwargs) -> None:
3939
"""Initialize self. See help(type(self)) for accurate signature."""
4040
@property
41-
def field_readonly(self) -> int: ...
41+
def field_readonly(self) -> int:
42+
"""some docstring
43+
(arg0: pybind11_fixtures.TestStruct) -> int
44+
"""
4245

4346
def func_incomplete_signature(*args, **kwargs):
4447
"""func_incomplete_signature() -> dummy_sub_namespace::HasNoBinding"""

test-data/pybind11_fixtures/expected_stubs_with_docs/pybind11_fixtures/demo.pyi

+28-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ __version__: str
55

66
class Point:
77
class AngleUnit:
8+
"""Members:
9+
10+
radian
11+
12+
degree"""
813
__members__: ClassVar[dict] = ... # read-only
914
__entries: ClassVar[dict] = ...
1015
degree: ClassVar[Point.AngleUnit] = ...
@@ -22,11 +27,23 @@ class Point:
2227
def __ne__(self, other: object) -> bool:
2328
"""__ne__(self: object, other: object) -> bool"""
2429
@property
25-
def name(self) -> str: ...
30+
def name(self) -> str:
31+
"""name(self: handle) -> str
32+
33+
name(self: handle) -> str
34+
"""
2635
@property
27-
def value(self) -> int: ...
36+
def value(self) -> int:
37+
"""(arg0: pybind11_fixtures.demo.Point.AngleUnit) -> int"""
2838

2939
class LengthUnit:
40+
"""Members:
41+
42+
mm
43+
44+
pixel
45+
46+
inch"""
3047
__members__: ClassVar[dict] = ... # read-only
3148
__entries: ClassVar[dict] = ...
3249
inch: ClassVar[Point.LengthUnit] = ...
@@ -45,9 +62,14 @@ class Point:
4562
def __ne__(self, other: object) -> bool:
4663
"""__ne__(self: object, other: object) -> bool"""
4764
@property
48-
def name(self) -> str: ...
65+
def name(self) -> str:
66+
"""name(self: handle) -> str
67+
68+
name(self: handle) -> str
69+
"""
4970
@property
50-
def value(self) -> int: ...
71+
def value(self) -> int:
72+
"""(arg0: pybind11_fixtures.demo.Point.LengthUnit) -> int"""
5173
angle_unit: ClassVar[Point.AngleUnit] = ...
5274
length_unit: ClassVar[Point.LengthUnit] = ...
5375
x_axis: ClassVar[Point] = ... # read-only
@@ -94,7 +116,8 @@ class Point:
94116
2. distance_to(self: pybind11_fixtures.demo.Point, other: pybind11_fixtures.demo.Point) -> float
95117
"""
96118
@property
97-
def length(self) -> float: ...
119+
def length(self) -> float:
120+
"""(arg0: pybind11_fixtures.demo.Point) -> float"""
98121

99122
def answer() -> int:
100123
'''answer() -> int

0 commit comments

Comments
 (0)