Skip to content
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: Adds ThemeConfig (TypedDict) #3536

Open
wants to merge 163 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
7b324d6
feat: Adds `SchemaInfo.is_format`
dangotbanned Aug 12, 2024
0325667
feat(typing): Annotate `SchemaProperties`
dangotbanned Aug 12, 2024
832fd72
perf: Use more appropriate data structures in `codegen`
dangotbanned Aug 12, 2024
549f42c
refactor: Reduce length and complexity of `get_python_type_representa…
dangotbanned Aug 12, 2024
1b6e008
refactor: Update `codegen` to use new `get_python_type_representation`
dangotbanned Aug 12, 2024
148c913
refactor(perf): Rewrite `generate_vegalite_mark_mixin`
dangotbanned Aug 12, 2024
de66450
perf: Iterate over `values()` when `keys()` are not needed
dangotbanned Aug 12, 2024
8fa63de
refactor: reorder `get_python_type_representation` kwargs
dangotbanned Aug 12, 2024
ba08256
feat(typing): Add missing annotations
dangotbanned Aug 12, 2024
5f35705
refactor: Rename `get_python_type_representation` -> `to_type_repr`
dangotbanned Aug 12, 2024
cb8aefc
refactor: Remove redundant `is_object` branch
dangotbanned Aug 12, 2024
193e493
fix: Exclude array stub classes
dangotbanned Aug 12, 2024
b2db86c
feat(typing): Temp solution for `dict` in `TypedDict`
dangotbanned Aug 12, 2024
566cd05
feat(typing): Add wip `ThemeConfig` implementation
dangotbanned Aug 12, 2024
aafe73f
build: run `generate-schema-wrapper`
dangotbanned Aug 12, 2024
f457a92
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Aug 12, 2024
5d1f2a5
docs: Add doc for `SchemaInfo.to_type_repr`
dangotbanned Aug 12, 2024
40cd566
fix: Use pre `3.12` fstring syntax
dangotbanned Aug 12, 2024
49633be
fix: Rerun `generate-schema-wrapper`
dangotbanned Aug 12, 2024
9c51d43
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Aug 13, 2024
b4f7ede
fix(typing): Exclude `core.Dict` from `format`
dangotbanned Aug 13, 2024
a8ac7ec
refactor: Replace `is_value()` case in `codegen.get_args()`
dangotbanned Aug 13, 2024
e4f62ec
fix(typing): Exclude `RelativeBandSize` from `discreteBandSize`
dangotbanned Aug 13, 2024
f23880f
feat(typing): Adds `Value` (`TypedDict`)
dangotbanned Aug 13, 2024
a9c8b99
build: run `generate-schema-wrapper`
dangotbanned Aug 13, 2024
184f2b6
ci(ruff): Enable lint/format on notebooks
dangotbanned Aug 13, 2024
91dacf8
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Aug 13, 2024
ecf7fd5
feat: Adds `SchemaInfo.is_type_alias`
dangotbanned Aug 14, 2024
f4cb0d4
build: run `generate-schema-wrapper`
dangotbanned Aug 14, 2024
a9a738e
refactor: Move, rename `_type_checking_only_imports` -> `import_type_…
dangotbanned Aug 14, 2024
fcb9469
feat: Adds `utils.import_typing_extensions`
dangotbanned Aug 14, 2024
7eea237
feat(typing): Adds `ColorHex`, `is_color_hex`
dangotbanned Aug 14, 2024
3455fd7
build: run `generate-schema-wrapper`
dangotbanned Aug 14, 2024
794e9d5
fix(typing): Exclude `str`, use `ColorHex | ColorName_T`
dangotbanned Aug 14, 2024
859e998
fix: Move *TODO* location
dangotbanned Aug 14, 2024
f09a14c
chore: Label a comment as a temp fix
dangotbanned Aug 14, 2024
da516c1
feat(typing): Adds `OverlayMarkDefKwds`
dangotbanned Aug 14, 2024
fc10816
refactor: Rename `types_from_title` -> `title_to_type_reprs`
dangotbanned Aug 14, 2024
ff1a3f5
fix: Don't escape braces, require full match for `ColorHex`
dangotbanned Aug 14, 2024
3b32cf7
docs: Add `ColorHex` example with transparency
dangotbanned Aug 14, 2024
7b1875d
test(typing): Adds `test_is_color_hex`
dangotbanned Aug 14, 2024
8ff7b00
refactor: Promote `title_to_type_reprs` to a `SchemaInfo` method
dangotbanned Aug 14, 2024
a59a7bd
perf: Optimize some checks in `SchemaInfo`
dangotbanned Aug 14, 2024
d68fcdb
feat: Use a dynamic `ClassVar` for remapping titles
dangotbanned Aug 14, 2024
e5c4b7f
feat(typing): Adds `LinearGradientKwds`, `RadialGradientKwds`
dangotbanned Aug 14, 2024
0c63dc7
fix: Include `ArgInfo.required` in `TypedDict`(s)
dangotbanned Aug 15, 2024
46fa848
feat(typing): Adds `GradientStopKwds`
dangotbanned Aug 15, 2024
d3f2898
ci: Remove old dependency `m2r` from `mypy`
dangotbanned Aug 15, 2024
db0419f
Merge remote-tracking branch 'upstream/main' into remove-m2r-mypy
dangotbanned Aug 15, 2024
da16406
Merge branch 'main' into config-typed-dict
dangotbanned Aug 15, 2024
7d3eac9
revert(ruff): Remove default `ruff` setting
dangotbanned Aug 15, 2024
4fd7628
feat(typing): Temporarily duplicate (#3538)
dangotbanned Aug 15, 2024
5a3f9ee
Merge pull request #1 from vega/remove-m2r-mypy
dangotbanned Aug 15, 2024
0ebc6bc
fix: Exclude titles w/ `SchemaInfo.additionalProperties`
dangotbanned Aug 15, 2024
a5e9442
feat: Fill out `MANUAL_DEFS` with all remaining targets
dangotbanned Aug 15, 2024
9b6c4d6
build: run `generate-schema-wrapper`
dangotbanned Aug 15, 2024
e2f0ed3
refactor: Renaming/tidying up new functions
dangotbanned Aug 15, 2024
f045dc6
refactor: Somewhat standardize imports
dangotbanned Aug 15, 2024
d435380
Merge & re-build
dangotbanned Aug 15, 2024
bb99389
feat(typing): Finish `ThemeConfig` hierarchy
dangotbanned Aug 15, 2024
67dc9df
Merge remote-tracking branch 'upstream/HEAD'
dangotbanned Aug 16, 2024
b24dbe2
Merge remote-tracking branch 'upstream/main'
dangotbanned Aug 16, 2024
964745a
Merge branch 'main' into config-typed-dict
dangotbanned Aug 16, 2024
3c9aab5
refactor: Tidy up `generate_schema_wrapper.py`
dangotbanned Aug 16, 2024
0be9f5d
perf: Reprioritise unreachable `info.allOf`
dangotbanned Aug 17, 2024
882013c
perf: Remove unused arg and compile pattern for `is_valid_identifier`
dangotbanned Aug 17, 2024
2781969
refactor(typing): Fill out some more generics
dangotbanned Aug 17, 2024
9e1c8c4
refactor(typing): Remove some `None` cases for `SchemaInfo`
dangotbanned Aug 17, 2024
b6fff04
Merge branch 'main' into config-typed-dict
dangotbanned Aug 27, 2024
cc6e9bd
Merge branch 'main' into config-typed-dict
dangotbanned Sep 1, 2024
9c94918
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Sep 3, 2024
1b3202b
Merge branch 'config-typed-dict' of https://github.com/dangotbanned/a…
dangotbanned Sep 3, 2024
11280df
chore: Remove outdated TODO
dangotbanned Sep 3, 2024
f6b4923
fix(typing): Resolve/ignore typing in `tools/`
dangotbanned Sep 3, 2024
a5bdd47
Merge branch 'main' into config-typed-dict
dangotbanned Sep 5, 2024
068c484
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Sep 6, 2024
9e35e30
docs: Add note on `RelativeBandSize` exclusion
dangotbanned Sep 7, 2024
2efe2ea
feat: Adds `SchemaProperties.__len__`
dangotbanned Sep 7, 2024
d922e4b
feat(typing): Enable type checking on `tools/`
dangotbanned Sep 7, 2024
1330708
refactor(typing): Fake immutability in `SchemaInfo`
dangotbanned Sep 7, 2024
230d625
refactor: Make `SchemaInfo` effectively immutable
dangotbanned Sep 7, 2024
a67755e
feat: Make `SchemaInfo` hashable
dangotbanned Sep 7, 2024
ae23b23
feat(DRAFT): Add WIP config schema sourcing
dangotbanned Sep 7, 2024
f62c82a
ci: Add patterns for `pyright`
dangotbanned Sep 7, 2024
a70f259
perf: Use cheaper comparison for `SchemaInfo.__eq__`
dangotbanned Sep 8, 2024
e40768e
refactor: `iter_children` -> `SchemaInfo.iter_descendants`
dangotbanned Sep 8, 2024
6334db0
feat: Avoid manual defs
dangotbanned Sep 8, 2024
2d89ad7
build: run `generate-schema-wrapper`
dangotbanned Sep 8, 2024
0af1cd1
feat: Adds `_config.__all__`
dangotbanned Sep 8, 2024
2670e3b
refactor: Un-special-case `Dict`, include in `SchemaInfo.is_type_alias`
dangotbanned Sep 9, 2024
6926973
Merge branch 'main' into config-typed-dict
dangotbanned Sep 9, 2024
836fc00
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Sep 9, 2024
ba70325
Merge branch 'config-typed-dict' of https://github.com/dangotbanned/a…
dangotbanned Sep 9, 2024
d63b8a6
docs: Update comments in `SchemaInfo.title_to_type_reprs`
dangotbanned Sep 9, 2024
ebfdbd4
refactor: `is_relevant_schema` -> `SchemaInfo.is_theme_config_target`
dangotbanned Sep 9, 2024
96a7460
refactor: Simplify `generate_config_typed_dicts`
dangotbanned Sep 9, 2024
b3a7fb3
docs: Link to discussion for unresolvable issue
dangotbanned Sep 9, 2024
aae8e6e
style: Use constant convention `FOR_TYPE_HINTS`
dangotbanned Sep 9, 2024
732b31d
feat(typing): Accept an `Iterator` in `indent_docstring`
dangotbanned Sep 9, 2024
5c33b2c
feat: Adds initial docs for `_config.py`
dangotbanned Sep 9, 2024
0a04d4d
build: run `generate-schema-wrapper`
dangotbanned Sep 9, 2024
7bb0b8e
Merge branch 'main' into config-typed-dict
dangotbanned Sep 9, 2024
b486f10
docs: Add summary for `ThemeConfig`
dangotbanned Sep 9, 2024
81349ea
test(typing): Adds `test_theme_config_typing`
dangotbanned Sep 9, 2024
b43deb5
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Sep 10, 2024
ff364a1
test: Remove `Vega`-only properties from theme tests
dangotbanned Sep 10, 2024
bf36b69
fix(typing): Misc typing fixes
dangotbanned Sep 10, 2024
79804ec
fix: Remove `Vega`-only properties from vendored `vega-themes.json`
dangotbanned Sep 10, 2024
0bdfa72
fix: Support hyphenated keys in `TypedDict`(s)
dangotbanned Sep 10, 2024
427a0dd
chore: Add note on remaining issue
dangotbanned Sep 10, 2024
6f13b0b
Merge remote-tracking branch 'upstream/main' into config-typed-dict
dangotbanned Sep 10, 2024
e564ca5
fix(DRAFT): Hack workaround for `Padding`
dangotbanned Sep 10, 2024
73f6b25
test: Adds `binste_altair_theme`
dangotbanned Sep 11, 2024
ab41cb7
test: Adds `husky_theme`
dangotbanned Sep 11, 2024
1dc4c05
test: Refactor, add runtime testing of `ThemeConfig`
dangotbanned Sep 11, 2024
5315a3d
refactor: Reuse `finalize_type_reprs`
dangotbanned Sep 11, 2024
c816ca3
chore: Rename `init_subclass_args` -> `metaclass_kwds`
dangotbanned Sep 11, 2024
7c55a35
refactor: Use only `generate_typed_dict` for `TypedDict`(s)
dangotbanned Sep 11, 2024
44624ef
refactor: Move `process_description` to `tools.schemapi.utils`
dangotbanned Sep 11, 2024
b5e54d8
docs: Add note to `SchemaGenerator.subclasses`
dangotbanned Sep 11, 2024
6d744f8
refactor: Include `process_description` in `deep_description`
dangotbanned Sep 11, 2024
dd05abd
perf: Replace relative links on entire description
dangotbanned Sep 11, 2024
bed1285
refactor(perf): Compile patterns and tidy up `fix_docstring_issues`
dangotbanned Sep 11, 2024
025aae5
chore: Remove unused code
dangotbanned Sep 11, 2024
9bc28d4
refactor: Factor out `_doc_args`, add `iter_args`
dangotbanned Sep 11, 2024
626401e
refactor: Remove unused `ruff_format_str`
dangotbanned Sep 11, 2024
a5c0567
refactor: Factor out `_signature_args`, enhance `ArgInfo.iter_args`
dangotbanned Sep 12, 2024
36fdaa6
refactor: Add `SchemaInfo.from_refname` constructor
dangotbanned Sep 12, 2024
1b236f9
docs: Add some missing docs
dangotbanned Sep 12, 2024
160ee63
refactor: Reorganize `.rst` utils to be together
dangotbanned Sep 12, 2024
7e85b36
refactor: Remove unused parameters
dangotbanned Sep 12, 2024
36ebca6
refactor: Move more constants into templates
dangotbanned Sep 12, 2024
7b7390a
refactor: Accept multiple remap titles
dangotbanned Sep 12, 2024
af7c17c
docs: Finish `generate_typed_dict`
dangotbanned Sep 12, 2024
072f512
feat(typing): Adds `RowCol` generic
dangotbanned Sep 12, 2024
007f373
feat(typing): Adds missing types for `TopLevelUnitSpec`
dangotbanned Sep 13, 2024
2afdc19
fix: Add `RowCol` to `_typing.__all__`
dangotbanned Sep 13, 2024
2c70eb6
fix: Version-gate `typing_extensions` in `utils`
dangotbanned Sep 13, 2024
ef3df18
feat: Support callables in `ArgInfo.iter_args`
dangotbanned Sep 13, 2024
4f3c0e7
feat: Define `ThemeConfig` as subset of `TopLevelUnitSpec`
dangotbanned Sep 13, 2024
ff01520
build: run `generate-schema-wrapper`
dangotbanned Sep 13, 2024
0b8eda8
test: Update `test_theme` to account for level correction
dangotbanned Sep 13, 2024
80b21d5
fix(typing): Use a single `TypeVar` for `RowCol`
dangotbanned Sep 13, 2024
810921c
feat(typing): Add `ThemeConfig` to `alt.typing`
dangotbanned Sep 13, 2024
79fb2fb
feat(typing): Update all `ThemeRegistry` annotations
dangotbanned Sep 13, 2024
c8ccb05
fix(typing): Satisfy `mypy` on `utils.core.update_nested`
dangotbanned Sep 13, 2024
26c6ede
fix: run `generate-schema-wrapper`
dangotbanned Sep 13, 2024
4933e54
feat(typing): Adds `PaddingKwds`
dangotbanned Sep 13, 2024
2847293
refactor: Factor out `_typed_dict_doc`
dangotbanned Sep 13, 2024
f386052
refactor: Factor out `_typed_dict_args`
dangotbanned Sep 13, 2024
ed24ada
docs: Update `generate_typed_dict`
dangotbanned Sep 13, 2024
ddf4636
refactor: Reuse `ArgInfo.iter_args` in `SchemaGenerator`
dangotbanned Sep 13, 2024
0c8f9e2
chore: Removed outdated comment
dangotbanned Sep 13, 2024
bf29786
Merge branch 'main' into config-typed-dict
dangotbanned Sep 16, 2024
cafd696
Update altair/vegalite/v5/schema/_typing.py
dangotbanned Sep 16, 2024
0bb7a86
fix: Apply suggested fix at source
dangotbanned Sep 16, 2024
ffb3214
style: Remove extra whitespace from docs
dangotbanned Sep 16, 2024
aaffebd
refactor: Reuse literals, add `_typing` dicts to `_config.__all__`
dangotbanned Sep 16, 2024
12b6410
feat: Export `_config.py` as `altair.typing.theme`
dangotbanned Sep 16, 2024
6e4af95
docs: Use `:class:` directive on `TypedDict`(s)
dangotbanned Sep 16, 2024
d4bd6db
fix: Define `typing` as a package to support submodules
dangotbanned Sep 16, 2024
8db4469
fix: Update `TypedDict` import in `_typing.py`
dangotbanned Sep 17, 2024
93334b7
Merge branch 'main' into config-typed-dict
dangotbanned Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions altair/typing.py → altair/typing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@
"ChartType",
"EncodeKwds",
"Optional",
"ThemeConfig",
"is_chart_type",
"theme",
]

from altair.typing import theme
from altair.typing.theme import ThemeConfig
from altair.utils.schemapi import Optional
from altair.vegalite.v5.api import ChartType, is_chart_type
from altair.vegalite.v5.schema.channels import (
Expand Down
1 change: 1 addition & 0 deletions altair/typing/theme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from altair.vegalite.v5.schema._config import * # noqa: F403
12 changes: 12 additions & 0 deletions altair/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,21 @@ def decorate(cb: WrapsFunc[R], /) -> WrappedMethod[T, P, R] | WrappedFunc[P, R]:
return decorate


@overload
def update_nested(
original: t.MutableMapping[Any, Any],
update: t.Mapping[Any, Any],
copy: Literal[False] = ...,
) -> t.MutableMapping[Any, Any]: ...
@overload
def update_nested(
original: t.Mapping[Any, Any],
update: t.Mapping[Any, Any],
copy: Literal[True],
) -> t.MutableMapping[Any, Any]: ...
def update_nested(
original: Any,
update: t.Mapping[Any, Any],
copy: bool = False,
) -> t.MutableMapping[Any, Any]:
"""
Expand Down
9 changes: 5 additions & 4 deletions altair/utils/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from __future__ import annotations

import sys
from typing import TYPE_CHECKING, Any, Dict
from typing import TYPE_CHECKING

from .plugin_registry import Plugin, PluginRegistry
from altair.utils.plugin_registry import Plugin, PluginRegistry
from altair.vegalite.v5.schema._config import ThemeConfig

if sys.version_info >= (3, 11):
from typing import LiteralString
Expand All @@ -16,12 +17,12 @@
from altair.utils.plugin_registry import PluginEnabler
from altair.vegalite.v5.theme import AltairThemes, VegaThemes

ThemeType = Plugin[Dict[str, Any]]
ThemeType = Plugin[ThemeConfig]
binste marked this conversation as resolved.
Show resolved Hide resolved


# HACK: See for `LiteralString` requirement in `name`
# https://github.com/vega/altair/pull/3526#discussion_r1743350127
class ThemeRegistry(PluginRegistry[ThemeType, Dict[str, Any]]):
class ThemeRegistry(PluginRegistry[ThemeType, ThemeConfig]):
def enable(
self, name: LiteralString | AltairThemes | VegaThemes | None = None, **options
) -> PluginEnabler:
Expand Down
Loading