Skip to content

Commit 1457a57

Browse files
committed
fix tests
1 parent 3073175 commit 1457a57

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mypy/stubgenc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,14 @@ def generate_function_stub(
540540
The 'class_name' is used to find signature of __init__ or __new__ in
541541
'class_sigs'.
542542
"""
543+
docstr: Any = getattr(obj, "__doc__", None)
544+
if not isinstance(docstr, str):
545+
docstr = None
546+
543547
ctx = FunctionContext(
544548
self.module_name,
545549
name,
546-
docstr=getattr(obj, "__doc__", None),
550+
docstr=docstr,
547551
is_abstract=self.is_abstract_method(obj),
548552
class_info=class_info,
549553
)

mypy/test/teststubgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ def test(arg0: str) -> None:
10971097
mod = ModuleType(self.__module__, "")
10981098
gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod)
10991099
gen.generate_function_stub("test", test, output=output)
1100-
assert_equal(output, ["def test(*args, **kwargs) -> Any: ..."])
1100+
assert_equal(output, ["def test(*args, **kwargs): ..."])
11011101
assert_equal(gen.get_imports().splitlines(), [])
11021102

11031103
def test_generate_c_property_with_pybind11(self) -> None:

0 commit comments

Comments
 (0)