From 5ecd80367118250155ef408f59af4d0931c5be0d Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Thu, 12 Dec 2024 13:38:00 +0100 Subject: [PATCH 1/4] wip change dep to taylors branch --- pyproject.toml | 2 +- src/scwidgets/code/_widget_code_input.py | 11 +++++++---- tests/test_code.py | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0ebe408..064d13c 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.git@flexi-docstring", "matplotlib", "termcolor" ] diff --git a/src/scwidgets/code/_widget_code_input.py b/src/scwidgets/code/_widget_code_input.py index 3c77bd6..83cd42f 100644 --- a/src/scwidgets/code/_widget_code_input.py +++ b/src/scwidgets/code/_widget_code_input.py @@ -8,7 +8,7 @@ import types import warnings from functools import wraps -from typing import Any, List, Optional, Tuple +from typing import Any, List, Optional, Tuple, Union from widget_code_input import WidgetCodeInput from widget_code_input.utils import ( @@ -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,13 @@ 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) -> Union[str, None]: docstring = function.__doc__ - return "" if docstring is None else textwrap.dedent(docstring) + return ( + None + if docstring is None + else textwrap.dedent(docstring).strip('"""') # noqa: B005 + ) @staticmethod def _get_function_source_and_def( diff --git a/tests/test_code.py b/tests/test_code.py index 16f9380..d03a375 100644 --- a/tests/test_code.py +++ b/tests/test_code.py @@ -79,6 +79,7 @@ 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" From caa22f3e8bc81aafc482318f1fc632e427296663 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Wed, 5 Mar 2025 08:37:27 +0100 Subject: [PATCH 2/4] switch to osscar-org remote, main branch --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 064d13c..4cce49f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ dependencies = [ "ipywidgets>=8.0.0", "numpy<2.0.0", - "widget_code_input @ git+https://github.com/agoscinski/widget-code-input.git@flexi-docstring", + "widget_code_input @ git+https://github.com/osscar-org/widget-code-input.git", "matplotlib", "termcolor" ] From bec250beb9e2c6e9dac9a47374c8588d8ac0f8c8 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Wed, 5 Mar 2025 16:19:17 +0100 Subject: [PATCH 3/4] update wci --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4cce49f..7bd4c9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ dependencies = [ "ipywidgets>=8.0.0", "numpy<2.0.0", - "widget_code_input @ git+https://github.com/osscar-org/widget-code-input.git", + "widget_code_input>=4.0.17", "matplotlib", "termcolor" ] From a8f4caae2bb21bf20060607a866f8ee28d66b172 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Wed, 5 Mar 2025 16:49:06 +0100 Subject: [PATCH 4/4] fix format error some stuff --- docs/src/getting_started.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/getting_started.ipynb b/docs/src/getting_started.ipynb index d8bfd7e..926c613 100644 --- a/docs/src/getting_started.ipynb +++ b/docs/src/getting_started.ipynb @@ -89,7 +89,7 @@ " update=update_func,\n", " update_mode=\"continuous\",\n", " title=\"Sinus function\",\n", - " description=\"Implements $\\sin(x\\omega)$\",\n", + " description=\"Implements $\\\\sin(x\\\\omega)$\",\n", ")\n", "\n", "code_ex.run_update() # For the demonstration we run the widget one time\n",