-
Notifications
You must be signed in to change notification settings - Fork 794
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
Type hints: Summary issue #2951
Labels
Comments
Yes, I like to be a reviewer in this process! |
I am in favor of making Altair a typed library. I would like to say that I can be help review and create PRs, but to be honest I haven't worked much with explicit types and it is unlikely that I will have time to learn about it in a reasonable timeframe, so I will likely not be of that much help here unfortunately. |
This was referenced May 27, 2023
Closed
This was referenced Jun 10, 2023
This was referenced Aug 6, 2023
Merged
Merged
This was referenced Nov 4, 2023
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, Altair only has a few type hints to help IDEs provide better autocompletion suggestions. More type hints would further help IDEs provide a better development experience as well as static type checkers to catch potential errors before they appear at runtime. Especially applications (e.g. a company-internal web application) and frameworks (e.g. Streamlit, Great Expectations) which want to tightly integrate with Altair could greatly profit from this.
I'd suggest the following approach for Altair which is in line with Using mypy with an existing codebase. Very open for inputs!
Should happen before the v5 release
v5 or minor release
I think it's preferable to have the following items more or less bundled into one release from which on Altair is declared as a library supporting type checks. This could be a minor release (5.1?) as it should not affect any runtime behaviour. Goal is to have as much as possible of the "public API" of Altair typed and then incrementally do the rest later on if we see value in it.
tests
folder which mypy can use for this.schemapi.py
: Type hint schemapi.py #3142altair/vegalite/v5/api.py
: Type hint api.py #3143Undefined
asUndefinedType
. Search for# Remove "ignore" statement once Undefined is no longer typed as Any
in code which was introduced in Type hints: Add static type checker mypy #2950 to make mypy pass.# type: ignore
and see if any of those mentions can now be removed or better type hinted_
. Search for_[A-Z]
to find them and convert to public types if they are used in public parts of the codebase. This way, others can use the types themselves for code that depends on Altair. This was discussed in this issue.py.typed
) as mentioned in the mypy docs (also note the mention ofzip_safe
and including the file in wheels and sdist, test this) → This allows mypy to use it when imported in other projects. Once Pylance shows non-public exports in completion suggestions microsoft/pylance-release#4059 is fixed we can also finish Restrict top-level autocompletion for VS Code (PyLance) #2927@mattijn @joelostblom Would you be open to this? Input on the release cycle? I could review PRs related to this topic and create some myself.
The text was updated successfully, but these errors were encountered: