Skip to content

Conversation

@tlauli
Copy link
Contributor

@tlauli tlauli commented Dec 12, 2025

Hi, I have two small improvements to static typing. This is my first contribution, so hopefully I did it right.

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Introduce ComponentSingleType, representing a singular renderable entity -> it is possible to render a list of these
    • Make _Wildcard type public by renaming it to Wildcard, and making it an Enum, which I feel better reflects the intent behind it, plays nice with static type-checkers and prevents users from doing funky stuff with it since it is now public (subclassing or instantiating anything other than the tree variants defined by dash)
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR.

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

Comment on lines +457 to +461
ComponentSingleType = typing.Union[str, int, float, Component, None]
# Renderable node type.
ComponentType = typing.Union[
str,
int,
float,
Component,
None,
typing.Sequence[typing.Union[str, int, float, Component, None]],
ComponentSingleType,
typing.Sequence[ComponentSingleType],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is also duplicated on generate components for backward compatibility. The template is here:

ComponentType = typing.Union[
str,
int,
float,
Component,
None,
typing.Sequence[typing.Union[str, int, float, Component, None]],
]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I replaced the duplicated code with import from the base_component, is that ok?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's for backward compatibility of generated components in external components libraries, if the library is built with the new imports but used with a previous version of dash it would not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. I removed the import and used the new type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be ok to replace the duplicated code with the import for 4.0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's really just building the components need to be backward compatible as we don't want to force components libraries to depend on a particular version of dash.

Copy link
Contributor

@T4rk1n T4rk1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃

@T4rk1n T4rk1n merged commit 502997d into plotly:dev Dec 17, 2025
6 of 7 checks passed
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.

2 participants