From be5e594f3ccfd5da6b77ff27c16b076e1db0be00 Mon Sep 17 00:00:00 2001 From: Hanjin Liu Date: Mon, 23 Oct 2023 18:23:25 +0900 Subject: [PATCH 1/2] fix typing of container kwargs --- src/magicgui/widgets/_concrete.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/magicgui/widgets/_concrete.py b/src/magicgui/widgets/_concrete.py index e2fc1d938..27940aa1f 100644 --- a/src/magicgui/widgets/_concrete.py +++ b/src/magicgui/widgets/_concrete.py @@ -611,9 +611,6 @@ class ListEdit(Container[ValueWidget[_V]]): ---------- value : Iterable, optional The starting value for the widget. - layout : str, optional - The layout for the container. must be one of ``{'horizontal', - 'vertical'}``. by default "horizontal" nullable : bool If `True`, the widget will accepts `None` as a valid value, by default `False`. options: dict, optional @@ -622,17 +619,18 @@ class ListEdit(Container[ValueWidget[_V]]): All additional keyword arguments are passed to `Container` constructor. """ - def __init__( # type: ignore [misc] # overlap between names + def __init__( self, value: Iterable[_V] | _Undefined = Undefined, - layout: str = "horizontal", nullable: bool = False, options: dict | None = None, - **kwargs: Unpack[ContainerKwargs], + **container_kwargs: Unpack[ContainerKwargs], ) -> None: self._args_type: type | None = None self._nullable = nullable - super().__init__(layout=layout, labels=False, **kwargs) + container_kwargs.setdefault("layout", "horizontal") + container_kwargs.setdefault("labels", False) + super().__init__(**container_kwargs) self.margins = (0, 0, 0, 0) if not isinstance(value, _Undefined): @@ -651,7 +649,7 @@ def __init__( # type: ignore [misc] # overlap between names button_plus = PushButton(text="+", name="plus") button_minus = PushButton(text="-", name="minus") - if layout == "horizontal": + if self.layout == "horizontal": button_plus.max_width = 40 button_minus.max_width = 40 @@ -864,9 +862,6 @@ class TupleEdit(Container[ValueWidget]): ---------- value : Iterable, optional The starting value for the widget. - layout : str, optional - The layout for the container. must be one of ``{'horizontal', - 'vertical'}``. by default "horizontal" nullable : bool If `True`, the widget will accepts `None` as a valid value, by default `False`. options: dict, optional @@ -885,7 +880,8 @@ def __init__( ) -> None: self._nullable = nullable self._args_types: tuple[type, ...] | None = None - container_kwargs["labels"] = False + container_kwargs.setdefault("labels", False) + container_kwargs.setdefault("layout", "horizontal") super().__init__(**container_kwargs) self._child_options = options or {} self.margins = (0, 0, 0, 0) From d17ee1833c19df5f9636af49cd231e6c039953ac Mon Sep 17 00:00:00 2001 From: Hanjin Liu Date: Mon, 23 Oct 2023 18:25:59 +0900 Subject: [PATCH 2/2] remove kwargs from Parameters section --- src/magicgui/widgets/_concrete.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/magicgui/widgets/_concrete.py b/src/magicgui/widgets/_concrete.py index 27940aa1f..9b60a4447 100644 --- a/src/magicgui/widgets/_concrete.py +++ b/src/magicgui/widgets/_concrete.py @@ -615,8 +615,6 @@ class ListEdit(Container[ValueWidget[_V]]): If `True`, the widget will accepts `None` as a valid value, by default `False`. options: dict, optional Widget options of child widgets. - **kwargs : Any - All additional keyword arguments are passed to `Container` constructor. """ def __init__( @@ -866,8 +864,6 @@ class TupleEdit(Container[ValueWidget]): If `True`, the widget will accepts `None` as a valid value, by default `False`. options: dict, optional Widget options of child widgets. - **kwargs : Any - All additional keyword arguments are passed to `Container` constructor. """ def __init__(