-
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
fix(typing): Improve Then
annotations, autocompletion, docs
#3567
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Purely demonstrating type checking behaviour for vega#3552 (comment)
Revisting these I found it confusing that they were defined like (A, B, B, A). They are now (A, A, B, B) so it is clearer how they are linked
Aiming to get all of these to pass, without breaking anything else. **CI fail expected**
dangotbanned
changed the title
fix(DRAFT): Add examples for
fix(DRAFT): Improve Sep 15, 2024
SchemaLike
Then
annotations, simplify autocompletion
…-compliant Can't define this in `OperatorMixin`, as `Expression` uses `{"type": "string"}`
Added a lot of notes here, since I was surpised `Then` would not be allowed in the cases I had planned originally
We're using a feature that didn't make it into `3.13` yet https://peps.python.org/pep-0728/
The warning raised by `pyright` here was actually quite helpful. Essentially, a shorthand string is never allowed here vega#3552 (comment)
We now provide more precise errors identifying exactly which call produced the issue. Previously, the `.then("min(foo):Q")` was silently allowed - but later rejected in `.otherwise()`.
I'm fairly sure this is fixed in another branch, so leaving this here for less of a conflict https://github.com/vega/altair/pull/3547/files#diff-bbe4e187b18d242a366c820d023afd89041759cb96e4ec66c3f34559a72c2f9d
No longer inherited
dangotbanned
commented
Sep 15, 2024
dangotbanned
commented
Sep 15, 2024
dangotbanned
commented
Sep 15, 2024
dangotbanned
commented
Sep 15, 2024
dangotbanned
commented
Sep 15, 2024
Removes the need for hardcoding restrictions in multiple places
…edDict`) - Adds some more consistency between `condition` and `when-then-otherwise` - 1 less thing to think about
This isn't a runtime concern, just to satisfy typing
Mostly pushing this as an experiment. Shortens signatures, but there is a cost to the indirection vega#3567 (comment)
dangotbanned
changed the title
fix(DRAFT): Improve
fix(typing): Improve Sep 16, 2024
Then
annotations, simplify autocompletionThen
annotations, autocompletion, docs
dangotbanned
commented
Sep 17, 2024
binste
approved these changes
Sep 22, 2024
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!
Thanks for the review @binste |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3552
Overview of issues by @binste in comment
The draft PR is very helpful! Trying to summarise/reword it for myself:
Then
should not inherit fromSchemaBase
as it muddies autocompletionSchemaBase
pass due toalt.condition
andalt.when().then().otherwise()
. Can beSchemaBase
or a protocolSchemaLike
. If I understand it correctly, we mainly introduce it now to make these types work.How about
Condition
is not yet used anywhere in the codebase and it makes it clearer what we intend to do with the protocol. What do you think?Tasks
Then
inChart.encode()
, without subclassingSchemaBase
Chart.encode()
annotations08bf16e
(#3567)(Condition|Schema)Like
d20109e
(#3567)TypeAlias|TypedDict
inapi.py
0a6d599
(#3567)0a93309
(#3567)Related
0bdfa72
(#3536)Note
This PR started as a draft proposal for addressing multiple related issues.
See #3552 (comment) for further info
Draft PR Demo
Purely demonstrating type checking behavior for #3552 (comment)
Extended chart_encode
Note
mypy
failing is expected and part of the demonstration