Skip to content

Commit c6ca0d5

Browse files
committed
Update tests
1 parent b229f27 commit c6ca0d5

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

mypy/stubgenc.py

Lines changed: 2 additions & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ __version__: str
55

66
class Point:
77
class AngleUnit:
8+
"""Members:
9+
radian
10+
11+
degree"""
812
__members__: ClassVar[dict] = ... # read-only
913
__entries: ClassVar[dict] = ...
1014
degree: ClassVar[Point.AngleUnit] = ...
@@ -22,11 +26,22 @@ class Point:
2226
def __ne__(self, other: object) -> bool:
2327
"""__ne__(self: object, other: object) -> bool"""
2428
@property
25-
def name(self) -> str: ...
29+
def name(self) -> str:
30+
"""name(self: handle) -> str
31+
32+
name(self: handle) -> str
33+
"""
2634
@property
27-
def value(self) -> int: ...
35+
def value(self) -> int:
36+
"""(arg0: pybind11_fixtures.demo.Point.AngleUnit) -> int"""
2837

2938
class LengthUnit:
39+
"""Members:
40+
mm
41+
42+
pixel
43+
44+
inch"""
3045
__members__: ClassVar[dict] = ... # read-only
3146
__entries: ClassVar[dict] = ...
3247
inch: ClassVar[Point.LengthUnit] = ...
@@ -45,9 +60,14 @@ class Point:
4560
def __ne__(self, other: object) -> bool:
4661
"""__ne__(self: object, other: object) -> bool"""
4762
@property
48-
def name(self) -> str: ...
63+
def name(self) -> str:
64+
"""name(self: handle) -> str
65+
66+
name(self: handle) -> str
67+
"""
4968
@property
50-
def value(self) -> int: ...
69+
def value(self) -> int:
70+
"""(arg0: pybind11_fixtures.demo.Point.LengthUnit) -> int"""
5171
angle_unit: ClassVar[Point.AngleUnit] = ...
5272
length_unit: ClassVar[Point.LengthUnit] = ...
5373
x_axis: ClassVar[Point] = ... # read-only
@@ -94,7 +114,8 @@ class Point:
94114
2. distance_to(self: pybind11_fixtures.demo.Point, other: pybind11_fixtures.demo.Point) -> float
95115
"""
96116
@property
97-
def length(self) -> float: ...
117+
def length(self) -> float:
118+
"""(arg0: pybind11_fixtures.demo.Point) -> float"""
98119

99120
def answer() -> int:
100121
'''answer() -> int

0 commit comments

Comments
 (0)