Skip to content

Commit 0e965e3

Browse files
author
Aaron Bevill
committed
Restrict accordion open param from Iterable to ListOrTuple per feedback on #2112
1 parent fe78239 commit 0e965e3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

shiny/express/ui/_cm_components.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
from __future__ import annotations
44

5-
from typing import Iterable, Literal, Optional
5+
from typing import Literal, Optional
66

77
from htmltools import Tag, TagAttrs, TagAttrValue, TagChild, TagFunction, TagList
88

99
from ... import ui
1010
from ..._deprecated import warn_deprecated
1111
from ..._docstring import add_example, no_example
12-
from ...types import DEPRECATED, MISSING, MISSING_TYPE
12+
from ...types import DEPRECATED, ListOrTuple, MISSING, MISSING_TYPE
1313
from ...ui._accordion import AccordionPanel
1414
from ...ui._card import CardItem
1515
from ...ui._layout_columns import BreakpointsUser
@@ -649,7 +649,7 @@ def card_footer(
649649
def accordion(
650650
*,
651651
id: Optional[str] = None,
652-
open: Optional[bool | str | Iterable[str]] = None,
652+
open: Optional[bool | str | ListOrTuple[str]] = None,
653653
multiple: bool = True,
654654
class_: Optional[str] = None,
655655
width: Optional[CssUnit] = None,

shiny/ui/_accordion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Literal, Iterable, Optional, TypeVar
3+
from typing import TYPE_CHECKING, Literal, Optional, TypeVar
44

55
from htmltools import Tag, TagAttrs, TagAttrValue, TagChild, css, tags
66

@@ -9,7 +9,7 @@
99
from .._utils import drop_none, private_random_id
1010
from ..bookmark import restore_input
1111
from ..session import require_active_session
12-
from ..types import MISSING, MISSING_TYPE
12+
from ..types import ListOrTuple, MISSING, MISSING_TYPE
1313
from ._html_deps_shinyverse import components_dependencies
1414
from ._tag import consolidate_attrs
1515
from .css._css_unit import CssUnit, as_css_unit
@@ -176,7 +176,7 @@ def tagify(self) -> Tag:
176176
def accordion(
177177
*args: AccordionPanel | TagAttrs,
178178
id: Optional[str] = None,
179-
open: Optional[bool | str | Iterable[str]] = None,
179+
open: Optional[bool | str | ListOrTuple[str]] = None,
180180
multiple: bool = True,
181181
class_: Optional[str] = None,
182182
width: Optional[CssUnit] = None,
@@ -264,9 +264,9 @@ def accordion(
264264
elif isinstance(open, bool):
265265
is_open = [open] * len(panels)
266266
else:
267-
# str | Iterable[str] -> set
268-
open = {open} if isinstance(open, str) else set(open)
269-
is_open = [panel._data_value in open for panel in panels]
267+
# str | ListOrTuple[str] -> set
268+
open_set = {open} if isinstance(open, str) else set(open)
269+
is_open = [panel._data_value in open_set for panel in panels]
270270

271271
if (not multiple) and sum(is_open) > 1:
272272
raise ValueError("Can't select more than one panel when `multiple = False`")

0 commit comments

Comments
 (0)