fix(types): Adapt to htmltools tagified-tag type system#2243
Closed
schloerke wants to merge 1 commit into
Closed
Conversation
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>
Collaborator
Author
|
Closing as duplicate of #2244. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates py-shiny to satisfy pyright against the new generic
Tag[ChildT]/TagList[ChildT]types and the tighterTagifiedreturn type of.tagify()introduced in posit-dev/py-htmltools#106.Tagifiedas the return type for all custom.tagify()methods (AccordionPanel,CardItem,NavSet*,Sidebar).Tagafterisinstance(x, Tag)narrowing where pyright producesTag[Unknown] | Tag[TagifiedNode]due to invariance (_navs._make_tabs_fillable,_page,_toolbar._extract_text,_utils._find_child_strings)..tagify()result back toTag | TagListbefore handing it toApp(which still operates on the narrower type), and avoid pyright narrowing ofobjectin_func_displayhook.test_sidebar.get_sidebar_tagsto index + cast rather than tuple-unpack aTagifiedvalue.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