diff --git a/pyproject.toml b/pyproject.toml index 0ebe408..5adcc72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ dependencies = [ "ipywidgets>=8.0.0", "numpy<2.0.0", - "widget_code_input>=4.0.13", + "widget_code_input @ git+https://github.com/agoscinski/widget-code-input@remove-docstring", "matplotlib", "termcolor" ] diff --git a/src/scwidgets/code/_widget_code_input.py b/src/scwidgets/code/_widget_code_input.py index 3c77bd6..6ec73bb 100644 --- a/src/scwidgets/code/_widget_code_input.py +++ b/src/scwidgets/code/_widget_code_input.py @@ -71,7 +71,6 @@ def __init__( if function_name is None: raise ValueError("function_name must be given if no function is given.") function_parameters = "" if function_parameters is None else function_parameters - docstring = "\n" if docstring is None else docstring function_body = "" if function_body is None else function_body self._builtins = {} if builtins is None else builtins super().__init__( @@ -152,9 +151,9 @@ def function_parameters_name(self) -> List[str]: return self.function_parameters.replace(",", "").split(" ") @staticmethod - def get_docstring(function: types.FunctionType) -> str: + def get_docstring(function: types.FunctionType) -> str | None: docstring = function.__doc__ - return "" if docstring is None else textwrap.dedent(docstring) + return None if docstring is None else textwrap.dedent(docstring) @staticmethod def _get_function_source_and_def( diff --git a/tests/test_code.py b/tests/test_code.py index e26c13f..dc02fe8 100644 --- a/tests/test_code.py +++ b/tests/test_code.py @@ -69,6 +69,9 @@ def test_get_function_paramaters(self): assert CodeInput.get_function_parameters(self.mock_function_7) == "x, **kwargs" def test_get_docstring(self): + assert ( + CodeInput.get_docstring(self.mock_function_0) is None + ) assert ( CodeInput.get_docstring(self.mock_function_1) == "\nThis is an example function.\nIt adds two numbers.\n"