-
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
feat: Reimplement expr
as a class that is understood by IDEs
#3466
Conversation
Fixes the mypy issue referenced in `alt.__init__.py`
The results of `_populate_namespace` were only visible in a `IPython` environment
…ngleton - all `ConstExpression`s are now read-only properties stored in a metaclass - `expr` subclasses `ExprRef`, replacing the `__call__` w/ `__new__` - No instances of `expr` are ever created - All `FunctionExpression`s are now classmethods - Each `Expression` can now be referenced in autocomplete, without needing `IPython`/`Jupyter` - Docstrings have been reformatted to be compatible with `sphinx` - Broken links in docstrings fixed (e.g. for d3) - class-level doc for `expr`, with references & doctest
Previously relied on the dynamic globals
Previously 2 tests, now 170+
Uses the section heading proposed in vega#3427 (comment) Expands on vega#2904
All tests are passing now 😀 I hope the recordings/screenshots are useful. I thought demonstrating the UX would be clearer than listing all the benefits this could have. Happy to clarify anything if you have any questions |
Hi @dangotbanned, thanks for this PR and apologies that no one has gotten back to you on it yet. This looks like a really nice quality of life improvement, and is very in line with my desire to promote the use of the expression API over using expression strings. I'll try to get to reviewing and playing with this later in the week if no one else gets to it faster |
I left this out initially, but by adding static `Parameter` names it is now possible
Can only second Jon's statement. Looks like a big UX improvement 🥳 but I struggle to find the time to review it. If you Jon get to it, that would be awesome! Thank you both :) |
These will all be superseded by vega#3466
This is an awesome improvement @dangotbanned. I like the architecture, just wondering if you have thoughts on reducing the duplication of function/constant specifications between the new class methods and the current Since we don't autogenerate these definitions right now, I want to go through the functions one-by-one before merging, and I'll do this later today or over the weekend. Not to address in this PR, but it would be nice to eventually be able to auto-generate these function definitions, but it looks like they aren't included in the Vega or Vega-Lite jsonschema definitions, so we would need to pull them directly from the Vega repo or something. |
Thanks @jonmmease
Yeah I considered this and would +1 for removing them. The related changes I'd like to see here are:
Good luck! There is a lot to read.
Yeah I looked into that as well and I couldn't see a clean way of doing so, but maybe someone more familiar with They're all defined in one place here https://vega.github.io/vega/docs/expressions/ But the actual source seems to be files like: |
@jonmmease all done on that front 👍 I'll hold of on my suggestion to remove, but this can now be done at any point in the future
|
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.
lgtm!
Thanks @jonmmease FYI I'm working on a fix for the |
Thanks! |
Is ready and would be able safely merge #3485 after Thank you again for reviewing |
Based on vega#3466 (comment) With some additional ignores added during test runs on `/v5/schema/*.py`
Related #2904
expr
ConstExpression
s are now read-only properties stored in a metaclassexpr
subclassesExprRef
, replacing the__call__
w/__new__
expr
are ever createdFunctionExpression
s are now classmethodsExpression
can now be referenced in autocomplete, without needingIPython
/Jupyter
Docs
sphinx
expr
, with references & doctestDemo
Current (IPython)
2024-06-20.13-30-20.Current.IPython.mp4
Current (Static)
2024-06-20.13-31-45.-.Current.Introspection.mp4
Proposed (Static)
2024-07-09.18-08-29.-.Improved.Introspection.mp4
Proposed (API Reference)