Skip to content

fix(types): Adapt to htmltools tagified-tag type system#2243

Closed
schloerke wants to merge 1 commit into
mainfrom
schloerke/htmltools-106-updates
Closed

fix(types): Adapt to htmltools tagified-tag type system#2243
schloerke wants to merge 1 commit into
mainfrom
schloerke/htmltools-106-updates

Conversation

@schloerke
Copy link
Copy Markdown
Collaborator

Summary

Updates py-shiny to satisfy pyright against the new generic Tag[ChildT] / TagList[ChildT] types and the tighter Tagified return type of .tagify() introduced in posit-dev/py-htmltools#106.

  • Use Tagified as the return type for all custom .tagify() methods (AccordionPanel, CardItem, NavSet*, Sidebar).
  • Cast to Tag after isinstance(x, Tag) narrowing where pyright produces Tag[Unknown] | Tag[TagifiedNode] due to invariance (_navs._make_tabs_fillable, _page, _toolbar._extract_text, _utils._find_child_strings).
  • Express: cast .tagify() result back to Tag | TagList before handing it to App (which still operates on the narrower type), and avoid pyright narrowing of object in _func_displayhook.
  • Update test_sidebar.get_sidebar_tags to index + cast rather than tuple-unpack a Tagified value.
  • Bump htmltools>=0.7.0.

Depends on posit-dev/py-htmltools#106. The version pin assumes that PR lands as htmltools 0.7.0 — adjust if the released version differs.

Test plan

Updates py-shiny to satisfy pyright against the new generic `Tag[ChildT]` /
`TagList[ChildT]` types and the tighter `Tagified` return type of
`.tagify()` introduced in posit-dev/py-htmltools#106.

- Use `Tagified` as the return type for all custom `.tagify()` methods
  (`AccordionPanel`, `CardItem`, `NavSet*`, `Sidebar`).
- Cast to `Tag` after `isinstance(x, Tag)` narrowing where pyright produces
  `Tag[Unknown] | Tag[TagifiedNode]` due to invariance (`_navs._make_tabs_fillable`,
  `_page`, `_toolbar._extract_text`, `_utils._find_child_strings`).
- Express: cast `.tagify()` result back to `Tag | TagList` before handing it
  to `App` (which still operates on the narrower type), and avoid pyright's
  `isinstance(..., Tag)` narrowing of `object` in `_func_displayhook`.
- Update `test_sidebar.get_sidebar_tags` to index + cast rather than tuple
  unpack a `Tagified` value.
- Bump `htmltools>=0.7.0`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@schloerke
Copy link
Copy Markdown
Collaborator Author

Closing as duplicate of #2244.

@schloerke schloerke closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant