fix(pyi): mark union props optional in generated stubs - #7080
Open
benedikt-bartscher wants to merge 2 commits into
Open
fix(pyi): mark union props optional in generated stubs#7080benedikt-bartscher wants to merge 2 commits into
benedikt-bartscher wants to merge 2 commits into
Conversation
`_get_type_hint` returned early for a union annotation and dropped the
`| None` the caller asked for, so a prop declared as a union got a stub
signature whose default contradicts its type:
content: Component | Var[str] | str = None
A non-union prop already went through the `is_optional` branch at the end
of the function and came out as `Var[bool] | bool | None`, so this only
ever hit props annotated as an explicit union — HighLevelTooltip.content,
HighLevelAccordion.items and Badge.color_scheme today. Type checkers flag
the generated signature itself; running pyright over the packages reports
five reportArgumentType errors that no source change can fix.
Honour `is_optional` in both union branches (typed and string
annotations). Only markdown.pyi changes among the tracked stubs.
benedikt-bartscher
force-pushed
the
fix-pyi-union-prop-optional
branch
from
September 10, 2026 20:53
b6c5cce to
8f0fbf6
Compare
Contributor
|
Merging this PR will not alter performance
Comparing Footnotes
|
benedikt-bartscher
marked this pull request as ready for review
September 12, 2026 18:29
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.
_get_type_hintreturned early for a union annotation and dropped the| Nonethe caller asked for, so a prop declared as a union got a stub signature whose default contradicts its type:A non-union prop already went through the
is_optionalbranch at the end of the function and came out asVar[bool] | bool | None, so this only ever hit props annotated as an explicit union — HighLevelTooltip.content, HighLevelAccordion.items and Badge.color_scheme today. Type checkers flag the generated signature itself; running pyright over the packages reports five reportArgumentType errors that no source change can fix.Honour
is_optionalin both union branches (typed and string annotations). Only markdown.pyi changes among the tracked stubs.