Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

dangotbanned
Copy link
Member

@dangotbanned dangotbanned commented Nov 3, 2024

I noticed a few problems with alt.binding during #3544.

Bug

We have one example (scatter_point_paths_hover) that uses the function.

Code reference

bind=alt.binding(input='search', placeholder="Country", name='Search ')

bind=alt.binding(input='search', placeholder="Country", name='Search ')

pyright - but not mypy - thinks there is an issue here and displays this warning:

image

Since the warning is being emitted - despite the example working as intended - I'd consider this a false-negative.

Besides the warning, you can see that:

  • the signature provides no information about arguments
  • the docstring also does not describe any parameters

This is not purely an issue with pyright, but can be seen in the API Reference.

Fix

The tests added in (0266b8d) demonstrate most of what is fixed.

However, a much bigger improvement can be seen in the now-meaningful signature and docstring for alt.binding:

image

These benefits will also be present in the 5.5.0 API Reference

- `Binding` is not generic, it is a union of all bindings
- It has no doc or parameters
- `binding()` currently forces this function to be `BindInput` as `input` is a required argument
- Discovered the backwards incompatibility during testing
- Manually spelling out the signature & copying the docs; was the only reliable method I found
- Ensures new signature is fully backwards compatible
- Demonstrates (previously) inconsistent typing behavior that is now resolved
@dangotbanned dangotbanned marked this pull request as ready for review November 3, 2024 16:00
@dangotbanned dangotbanned enabled auto-merge (squash) November 3, 2024 16:00
@dangotbanned dangotbanned merged commit c28dbb9 into main Nov 3, 2024
21 checks passed
@dangotbanned dangotbanned deleted the binding-input branch November 3, 2024 16:22
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 this pull request may close these issues.

1 participant