|
8 | 8 | import types |
9 | 9 | import warnings |
10 | 10 | from functools import wraps |
11 | | -from typing import Any, List, Optional, Tuple |
| 11 | +from typing import Any, List, Optional, Tuple, Union |
12 | 12 |
|
13 | 13 | from widget_code_input import WidgetCodeInput |
14 | 14 | from widget_code_input.utils import ( |
@@ -71,7 +71,6 @@ def __init__( |
71 | 71 | if function_name is None: |
72 | 72 | raise ValueError("function_name must be given if no function is given.") |
73 | 73 | function_parameters = "" if function_parameters is None else function_parameters |
74 | | - docstring = "\n" if docstring is None else docstring |
75 | 74 | function_body = "" if function_body is None else function_body |
76 | 75 | self._builtins = {} if builtins is None else builtins |
77 | 76 | super().__init__( |
@@ -152,9 +151,11 @@ def function_parameters_name(self) -> List[str]: |
152 | 151 | return self.function_parameters.replace(",", "").split(" ") |
153 | 152 |
|
154 | 153 | @staticmethod |
155 | | - def get_docstring(function: types.FunctionType) -> str: |
| 154 | + def get_docstring(function: types.FunctionType) -> Union[str, None]: |
156 | 155 | docstring = function.__doc__ |
157 | | - return "" if docstring is None else textwrap.dedent(docstring) |
| 156 | + |
| 157 | + ds= None if docstring is None else textwrap.dedent(docstring).strip('"""') |
| 158 | + return ds |
158 | 159 |
|
159 | 160 | @staticmethod |
160 | 161 | def _get_function_source_and_def( |
|
0 commit comments