Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channels.py parameters, properties types too strict #3572

Closed
dangotbanned opened this issue Sep 6, 2024 · 0 comments · Fixed by #3573
Closed

channels.py parameters, properties types too strict #3572

dangotbanned opened this issue Sep 6, 2024 · 0 comments · Fixed by #3573
Labels

Comments

@dangotbanned
Copy link
Member

dangotbanned commented Sep 6, 2024

What happened?

While rewriting some alt.condition(s) to alt.when(s) in #3544 I came across some examples that work correctly - but upset a type checker.

Minimal Repro

Code block

import altair as alt
from vega_datasets import data

source = data.cars()
color = (
    alt.when(alt.datum.Weight_in_lbs >= 3500)
    .then(alt.value("hotpink"))
    .otherwise(alt.value("goldenrod"))
)

chart = (
    alt.Chart(source, width=300, height=150)
    .mark_rect()
    .encode(
        x=alt.X("Cylinders:N").axis(labelColor=color),
        y=alt.Y("Origin:N", axis=alt.Axis(tickColor=color)),
        color=color,
    )
)
chart

Screenshot Didn't promise it looks pretty, but the spec validates

image

Solution

The issue is unrelated to #3552, and can instead reuse the solution from #3458.

Not expecting this will require any runtime changes.

However, it will very likely create a huge diff since so much of the generated code will have changes like below:

Map: TypeAlias = Mapping[str, Any]

before: dict | SchemaBase
after: Map | SchemaBase

Creating an issue for visibility and to note that it will need to be merged before #3544 to avoid needing to ignore typing for examples

What would you like to happen instead?

Not require # type: ignore comments for expected use of public API.

Which version of Altair are you using?

5.4.0, 5.4.1, 5.5.0dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant