From 1457a57a07a9f84c024c1f0cb8e31719a4a9bd2d Mon Sep 17 00:00:00 2001 From: Chad Dombrova Date: Wed, 2 Aug 2023 15:51:48 -0700 Subject: [PATCH] fix tests --- mypy/stubgenc.py | 6 +++++- mypy/test/teststubgen.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mypy/stubgenc.py b/mypy/stubgenc.py index 85da6bb324e5e..27bcbd380ff33 100755 --- a/mypy/stubgenc.py +++ b/mypy/stubgenc.py @@ -540,10 +540,14 @@ def generate_function_stub( The 'class_name' is used to find signature of __init__ or __new__ in 'class_sigs'. """ + docstr: Any = getattr(obj, "__doc__", None) + if not isinstance(docstr, str): + docstr = None + ctx = FunctionContext( self.module_name, name, - docstr=getattr(obj, "__doc__", None), + docstr=docstr, is_abstract=self.is_abstract_method(obj), class_info=class_info, ) diff --git a/mypy/test/teststubgen.py b/mypy/test/teststubgen.py index b96aad8c89b00..5f84c9e300f6b 100644 --- a/mypy/test/teststubgen.py +++ b/mypy/test/teststubgen.py @@ -1097,7 +1097,7 @@ def test(arg0: str) -> None: mod = ModuleType(self.__module__, "") gen = InspectionStubGenerator(mod.__name__, known_modules=[mod.__name__], module=mod) gen.generate_function_stub("test", test, output=output) - assert_equal(output, ["def test(*args, **kwargs) -> Any: ..."]) + assert_equal(output, ["def test(*args, **kwargs): ..."]) assert_equal(gen.get_imports().splitlines(), []) def test_generate_c_property_with_pybind11(self) -> None: