-
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.
Type hints: Infer types from vegalite schema for autogenerated code (#…
…3208) * Include schema files in mypy type checking * Use actual names of Python types in docstrings * Simplify medium_description by removing unused code paths * Use Python type hint syntax instead of pseudo jsonschema syntax in docstrings * First version of autoinferred type hints * Various improvements * Add type hints to mixins.py * Bug fix: Add missing overload operators * Add type hints to arguments of overload signatures where the signature has multiple arguments with Undefined default value * Add type hint for Parameter * Deduplicate type hints * Minor renaming and reordering of type hints * Recursively go through types to get all for type hints as well as docstrings * Instead of writing a List of Unions, do it the other way around and do not allow for combinations of different types in lists. This deals with the invariance of lists * Use Sequence instead of List * Simplify code * Remove unused ignore statement. Seems like mypy can now correctly detect that the overload statements are correct * Switch to tooltip specification which conforms to type hints * Ignore mypy errors when it cannot detect the existence of the .copy method * Explicitly pass kwarg arguments in these examples * Fix schema for 'shorthand' as it also accepts an array of strings * Revert "Switch to tooltip specification which conforms to type hints" This reverts commit 54439c8. * Fix some more mypy errors * Ignore mypy overload errors * Black and ruff * Add type hints to channel mixins * Simplify docstrings by removing Union so they look better in docs. Remove type hints from signatures in docs as they are already shown in docstrings * Fix merge conflicts and rerun schema generation * Remove redundat capability with VL v2 * Factor out adding shorthand into a separate function. Fix missing Field class definitions in docstring where previously only shorthand was shown * Add missing shorthand to field definitions in core.py * Add shorthand str and list[str] type hints to signature of encode method * Fix various mypy errors * Fix mypy error for data argument. Add RepeatRef as a type hint for shorthand * Add _ParameterProtocol wherever ParameterExtent is accepted * Switch to ruff as code formatter * Ruff fix * Move type ignore comment which was shifted by Ruff * Try to fix mypy issue in pipeline which does not appear locally * Change type signature of encode method to only include the types which users expect * Only show type hints for datum and value if they are accepted * Fix trailing whitespace * Switch back to just 'dict' * Add type hint for list to encoding channels which support it * Rename _ParameterProtocol to _Parameter * Fix ruff error * Add parameters incl. type hints to docstrings. Without descriptions for now * Add descriptions * Change import statement for expr.core to help type checkers
- Loading branch information
Showing
16 changed files
with
134,472 additions
and
13,028 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
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# ruff: noqa | ||
|
||
from .core import * | ||
from .channels import * | ||
SCHEMA_VERSION = 'v5.15.1' | ||
SCHEMA_URL = 'https://vega.github.io/schema/vega-lite/v5.15.1.json' | ||
from .channels import * # type: ignore[assignment] | ||
|
||
SCHEMA_VERSION = "v5.15.1" | ||
|
||
SCHEMA_URL = "https://vega.github.io/schema/vega-lite/v5.15.1.json" |
Oops, something went wrong.