-
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
feat: Generate expr
method signatures, docs
#3600
Conversation
Similar idea to `inspect.Parameter`
Similar to `inspect.Signature`
- Only the most common case - no docs - No method body
Currently just collects the pieces, but doesn't render the final str
Also renamed constant `EXPR_ANNOTATION` -> `INPUT_ANNOTATION`
- Contains all the functionality - Needs a lot of tidying up
- Uses the same config as `indent_docstring` - Can't truly be `numpydoc` though without a parameters section
@mattijn I managed to get all of these working correctly: # ruff: noqa: B018
import altair as alt
# import altair.expr as ae
from altair import expr
from altair import expr as ae
from altair.expr import expr as expr_cls
alt.expr.scale
expr.scale
ae.scale
expr_cls.scale EditAFAIK this behavior isn't something I'd expect to have changed vs |
Well spotted @mattijn thank you! I'll follow this up in #3600 (comment) |
Not fully convinced this is a reliable alterntive to manually maintaining #3600 (comment)
…sion` - Found this to be a much more reliable source - Won't require manual syncing - Can easily be replaced in the future with a public function/attribute accessible in `vl_convert` itself #3600 (comment)
Note@mattijn I'm moving into draft to utilize #3633 and simplify #3600 (comment) |
Also moves away from using the legacy `python2` interace https://docs.python.org/3/library/urllib.request.html#legacy-interface
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 this PR. Looks good now!
Thanks for your help with this PR @mattijn One last thing I'd like to check before merging, from the Deferred section of the description
I can either:
|
Option 3 is OK 👍 |
Closes #3563
Description
This PR builds on the work of #3466, and provides accurate signatures for
alt.expr
methods.Benefits
Originally listed in #3563 (comment)
TypeError
at the time ofexpr
definitionChartType
python
and notjavascript
expr
and the missing argument""
for theelseValue
Screenshots
Implementation
In #3563 I proposed authoring these changes manually.
However, after revisiting a conversation I had with @jonmmease I thought it would be worth at least trying to generate the definitions.
I found that https://vega.github.io/vega/docs/expressions/ seemed to be the only place they are documented in a single place.
From my understanding, this document is manually maintained but updates occur infrequently.
There was enough consistency in the markup used to work out how various parameters aligned with
python
syntax https://docs.python.org/3/tutorial/controlflow.html#special-parameters.I also used this opportunity to clean up the docs themselves, and get them closer to the rest of
altair
.There is definitely more that could be explored on that front, and some of the changes here could be utilised to improve the existing generated docs.
Related
expr
as a class that is understood by IDEs #3466Tasks
py
-equivalent signaturesaltair
functionsbackticks
for own parametersmistune
escapingtest_expr.py
to account for number of arguments relatedalt.expr.__init__.py
.rst
stuff commitvega_expr.py
expr
method signatures, docs #3600 (review)Deferred
Trying my best to keep the scope of the PR focused.
Working on this sparked a lot of ideas, so I've collected those here to possibly explore in the future:
expressions.md
tools.schemapi.vega_expr.py
->tools.vega_expr.py
vega-lite
schemaexpr
methods, replace w/ snake_case_ExprMeta.__getattr__
would make this possible(Early) Preview
Prior to
5e75051
(#3600) there wasn't any generated source on this branch.Keeping these screenshots for a quick reference
until I've resolved some test issues.Screenshots