-
Notifications
You must be signed in to change notification settings - Fork 795
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
fix: Restrict static & runtime top-level imports #3482
Conversation
This missing is the main source of unpredictable imports. I've explicitly not included the `Mixin` classes, side effect imports (e.g. `Undefined`, `parse_shorthand`, `@overload`) and `@with_property_setters`
This was the only side-effect import that I imagine was useful
Previously imported in `api` -> here
Currently not included deprecations, but will probably have to revert later
Dropped from top-level: `DataType`, `TOPLEVEL_ONLY_KEYS`, `mixins`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this! I've added one question as a comment. Also, in #3454 (comment) you say that this PR is an opportunity to discuss the boundaries of what we want to consider as breaking. Are you aware of anything in this PR that could be considered a breaking change? Probably the removal of some entries from the top-level Altair namespace? I'm wondering if we want to re-add them and only fix the pylance related autocompletion in this PR. Cleaning up the top-level namespace could be a bigger initiative to tackle for v6. thoughts?
Thank you @binste for reviewing!
"Breaking" Changes (
|
This helps, thanks! May I propose that this PR is changed to only fix the regression in the pylance autocompletion without removing elements from the top-level namespace. I think it's great that you push the discussion forward of what we want to consider the "public" part of the API and what guarantees we offer users. I see a lot of value in defining this. I'd prefer if we look at defining the public API in one go holistically by going through all elements in a systematic way. By doing it in one go, we can hopefully reduce frictions for end users and provide clear indication of the changes, migration guides, and a guarantee of what is public going forward. It will involve tradeoffs between making Altair better for future users while not breaking too many things for existing codebases and users. Discussing this topic with an overview of all the parts of the package hopefully allows us to get this right. Thanks again for continue to push Altair in a better direction! Much appreciated :) |
Thank you @binste
That is absolutely fine with me! |
altair/__init__.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binste altair.__all__
is now identical to main 👍
That's perfect, thank you! :) |
Fixes: #3478 (comment)
Supersedes: #2927
Description
This PR is primarily fixing
pylance
autocompletion that has regressed since #3431However, this also required some runtime changes, which have been spread across commits to more clearly document what is/isn't accessible and where.
Autocomplete
Before
After
_T
aliasesalt.annotations
)Any
will be removed following feat: Reimplementexpr
as a class that is understood by IDEs #3466pylance
__all__
changesEvery instance of
from module_name import *
has either:module_name
declares an__all__
, which is what gets importedimport *
can be followed until reaching a defined__all__
2024-07-17.10-45-47.-.Wildcard.follow.mp4
Extra
An added bonus seems to be
@deprecated
is being recognised intests/**
Note: deprecated functions still appear, but the visual cue & warning will be displayed