Skip to content

Commit 712680b

Browse files
dangotbannedbinste
andauthored
feat: Adds ThemeConfig (TypedDict) (#3536)
Co-authored-by: Stefan Binder <[email protected]>
1 parent eb6febd commit 712680b

File tree

18 files changed

+10121
-772
lines changed

18 files changed

+10121
-772
lines changed

altair/typing.py renamed to altair/typing/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@
4646
"ChartType",
4747
"EncodeKwds",
4848
"Optional",
49+
"ThemeConfig",
4950
"is_chart_type",
51+
"theme",
5052
]
5153

54+
from altair.typing import theme
55+
from altair.typing.theme import ThemeConfig
5256
from altair.utils.schemapi import Optional
5357
from altair.vegalite.v5.api import ChartType, is_chart_type
5458
from altair.vegalite.v5.schema.channels import (

altair/typing/theme.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from altair.vegalite.v5.schema._config import * # noqa: F403

altair/utils/core.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,21 @@ def decorate(cb: WrapsFunc[R], /) -> WrappedMethod[T, P, R] | WrappedFunc[P, R]:
771771
return decorate
772772

773773

774+
@overload
774775
def update_nested(
775776
original: t.MutableMapping[Any, Any],
776777
update: t.Mapping[Any, Any],
778+
copy: Literal[False] = ...,
779+
) -> t.MutableMapping[Any, Any]: ...
780+
@overload
781+
def update_nested(
782+
original: t.Mapping[Any, Any],
783+
update: t.Mapping[Any, Any],
784+
copy: Literal[True],
785+
) -> t.MutableMapping[Any, Any]: ...
786+
def update_nested(
787+
original: Any,
788+
update: t.Mapping[Any, Any],
777789
copy: bool = False,
778790
) -> t.MutableMapping[Any, Any]:
779791
"""

altair/utils/theme.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from __future__ import annotations
44

55
import sys
6-
from typing import TYPE_CHECKING, Any, Dict
6+
from typing import TYPE_CHECKING
77

8-
from .plugin_registry import Plugin, PluginRegistry
8+
from altair.utils.plugin_registry import Plugin, PluginRegistry
9+
from altair.vegalite.v5.schema._config import ThemeConfig
910

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

19-
ThemeType = Plugin[Dict[str, Any]]
20+
ThemeType = Plugin[ThemeConfig]
2021

2122

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

0 commit comments

Comments
 (0)