-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typing): Adds public
altair.typing
module (#3515)
* feat(typing): Create `altair.typing` #3514 * chore: Add comment on `tooltip` annotation Trying to trigger some places to add github comments - for actual threads * feat(typing): Add reference impl `EncodeKwds` from comment * feat(typing): Use `OneOrSeq[tps]` instead of `Union[*tps, list]` in `.encode()` * build: run `generate-schema-wrapper` * wip: generate `typed_dict_args` * refactor: Simplify `tools`, remove redundant code Pushing this mid-refactor of `_create_encode_signature`. Currently 0 changes to generated code * refactor: finish removing `altair_classes_prefix` * feat: `_create_encode_signature()` -> `EncodingArtifacts` Refactored, moved comments into docs, parameterised globals * build: run `generate-schema-wrapper` * feat(typing): Provide a public export for `_EncodeKwds` * Add docstring to _EncodeKwds * Rewrite EncodeArtifacts dataclass as a function * Fix ruff issue due to old local ruff version * Change generate_encoding_artifacts to an iterator * docs: run `generate-schema-wrapper` with `indent_level=4` I prefer the original, but this is to clarify #3515 (comment) * feat(typing): Move `ChartType`, `is_chart_type` to `alt.typing` These aren't introduced until `5.4.0`, so this is keeps the top-level from growing +2 #3515 (comment) * revert(ruff): Restore original ('RUF001`) line 1eb466d * Add type aliases for each channel * Format * Use Union instead of | for compatibility with Py <3.10 * Add channel type aliases to typing module. Add 'Type hints' section to API references in docs. Remove is_chart_type from 'API' docs section as it's now in typing. Rename '_EncodeKwds' to 'EncodeKwds' * chore(ruff): Remove unused `F401` ignore Would have only been needed before adding an `__all__` * feat(typing): Move `Optional` export to `typing` Updates all references, docs, `ruff` rule * refactor: Move blank line append to `indent_docstring` If this is needed for every call, it belongs in the function itself * docs(typing): Remove empty type list from `EncodeKwds` * refactor: Renaming, grouping, reducing repetition * refactor: More tidying up, annotating, reformat * docs: Reference aliases in `generate_encoding_artifacts` * Use full type hints instead of type alias in signatures for typeddict and encode method * Rename 'Type hints' to 'Typing' * Ruff fix --------- Co-authored-by: Stefan Binder <binder_stefan@outlook.com>
- Loading branch information
1 parent
6d69bfb
commit ee7fd19
Showing
16 changed files
with
648 additions
and
186 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
"""Public types to ease integrating with `altair`.""" | ||
|
||
from __future__ import annotations | ||
|
||
__all__ = [ | ||
"ChannelAngle", | ||
"ChannelColor", | ||
"ChannelColumn", | ||
"ChannelDescription", | ||
"ChannelDetail", | ||
"ChannelFacet", | ||
"ChannelFill", | ||
"ChannelFillOpacity", | ||
"ChannelHref", | ||
"ChannelKey", | ||
"ChannelLatitude", | ||
"ChannelLatitude2", | ||
"ChannelLongitude", | ||
"ChannelLongitude2", | ||
"ChannelOpacity", | ||
"ChannelOrder", | ||
"ChannelRadius", | ||
"ChannelRadius2", | ||
"ChannelRow", | ||
"ChannelShape", | ||
"ChannelSize", | ||
"ChannelStroke", | ||
"ChannelStrokeDash", | ||
"ChannelStrokeOpacity", | ||
"ChannelStrokeWidth", | ||
"ChannelText", | ||
"ChannelTheta", | ||
"ChannelTheta2", | ||
"ChannelTooltip", | ||
"ChannelUrl", | ||
"ChannelX", | ||
"ChannelX2", | ||
"ChannelXError", | ||
"ChannelXError2", | ||
"ChannelXOffset", | ||
"ChannelY", | ||
"ChannelY2", | ||
"ChannelYError", | ||
"ChannelYError2", | ||
"ChannelYOffset", | ||
"ChartType", | ||
"EncodeKwds", | ||
"Optional", | ||
"is_chart_type", | ||
] | ||
|
||
from altair.utils.schemapi import Optional | ||
from altair.vegalite.v5.api import ChartType, is_chart_type | ||
from altair.vegalite.v5.schema.channels import ( | ||
ChannelAngle, | ||
ChannelColor, | ||
ChannelColumn, | ||
ChannelDescription, | ||
ChannelDetail, | ||
ChannelFacet, | ||
ChannelFill, | ||
ChannelFillOpacity, | ||
ChannelHref, | ||
ChannelKey, | ||
ChannelLatitude, | ||
ChannelLatitude2, | ||
ChannelLongitude, | ||
ChannelLongitude2, | ||
ChannelOpacity, | ||
ChannelOrder, | ||
ChannelRadius, | ||
ChannelRadius2, | ||
ChannelRow, | ||
ChannelShape, | ||
ChannelSize, | ||
ChannelStroke, | ||
ChannelStrokeDash, | ||
ChannelStrokeOpacity, | ||
ChannelStrokeWidth, | ||
ChannelText, | ||
ChannelTheta, | ||
ChannelTheta2, | ||
ChannelTooltip, | ||
ChannelUrl, | ||
ChannelX, | ||
ChannelX2, | ||
ChannelXError, | ||
ChannelXError2, | ||
ChannelXOffset, | ||
ChannelY, | ||
ChannelY2, | ||
ChannelYError, | ||
ChannelYError2, | ||
ChannelYOffset, | ||
EncodeKwds, | ||
) |
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
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
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
Oops, something went wrong.