Skip to content

Commit 54b0402

Browse files
authored
chore: More minor type changes in prep for py-htmltools updates (#1693)
1 parent 9d663fb commit 54b0402

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

shiny/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def resolve(
209209
"""
210210
...
211211

212-
def get_value(self) -> Optional[str]:
212+
def get_value(self) -> str | None:
213213
"""
214214
Get the value of this navigation item (if any).
215215

shiny/ui/_navs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ def resolve(
9191

9292
return nav, content
9393

94-
def get_value(self) -> str | HTML | None:
94+
def get_value(self) -> str | None:
9595
if self.content is None:
9696
return None
9797
a_tag = cast(Tag, self.nav.children[0])
98-
return a_tag.attrs.get("data-value", None)
98+
data_value_attr = a_tag.attrs.get("data-value", None)
99+
if isinstance(data_value_attr, HTML):
100+
data_value_attr = str(data_value_attr)
101+
return data_value_attr
99102

100103
def tagify(self) -> None:
101104
raise NotImplementedError(
@@ -279,7 +282,7 @@ def resolve(
279282
content.children,
280283
)
281284

282-
def get_value(self) -> Optional[str]:
285+
def get_value(self) -> str | None:
283286
for x in self.nav_controls:
284287
val = x.get_value()
285288
if val:

0 commit comments

Comments
 (0)