Skip to content

Commit

Permalink
feat: Adds vega-themes.json using vl_convert (#3523)
Browse files Browse the repository at this point in the history
* feat: Adds `vega-themes.json` using `vl_convert`

#3519 (comment)

* Update vega-themes.json

* fix: Force LF

* fix: Use `sort_keys` for deterministic `vega-themes.json`

* build: run `generate-schema-wrapper`

* ci: Introduce `vl_convert` dependency to GH `Test that schema generation has no effect`

#3519 (comment)

https://github.com/vega/altair/actions/runs/10263632193/job/28395892206?pr=3523

* ci: Output diff when schema generation has an effect

Not sure of the right command here, as I can't repro locally

* ci: Change gitattributes to always LF

* fix: re-run with fresh env

#3523 (comment)

* feat(typing): Generate `VegaThemes` alias

Resolves the *long-term* solution mentioned in #3519 (comment)
  • Loading branch information
dangotbanned authored Aug 8, 2024
1 parent ee7fd19 commit 3e9faaa
Show file tree
Hide file tree
Showing 7 changed files with 1,344 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* text=auto
* text=auto eol=lf
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
pip install pandas==0.25.3 numpy==1.17.5
- name: Test that schema generation has no effect
run: |
pip install vl-convert-python
python tools/generate_schema_wrapper.py
# This gets the paths of all files which were either deleted, modified
# or are not yet tracked by Git
Expand All @@ -60,6 +61,7 @@ jobs:
if [ ${#files_cleaned[@]} -gt 0 ]; then
echo "The code generation modified the following files:"
echo $files
git diff
exit 1
fi
- name: Test with pytest
Expand Down
4 changes: 2 additions & 2 deletions altair/utils/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

if TYPE_CHECKING:
from altair.utils.plugin_registry import PluginEnabler
from altair.vegalite.v5.theme import _ThemeName
from altair.vegalite.v5.theme import AltairThemes, VegaThemes

ThemeType = Callable[..., dict]


class ThemeRegistry(PluginRegistry[ThemeType, dict]):
def enable(
self, name: LiteralString | _ThemeName | None = None, **options
self, name: LiteralString | AltairThemes | VegaThemes | None = None, **options
) -> PluginEnabler:
"""
Enable a theme by name.
Expand Down
17 changes: 17 additions & 0 deletions altair/vegalite/v5/schema/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"TitleOrient_T",
"TypeForShape_T",
"Type_T",
"VegaThemes",
"WindowOnlyOp_T",
]

Expand All @@ -76,6 +77,22 @@ def func(
): ...
"""

VegaThemes: TypeAlias = Literal[
"carbong10",
"carbong100",
"carbong90",
"carbonwhite",
"dark",
"excel",
"fivethirtyeight",
"ggplot2",
"googlecharts",
"latimes",
"powerbi",
"quartz",
"urbaninstitute",
"vox",
]
Map: TypeAlias = Mapping[str, Any]
AggregateOp_T: TypeAlias = Literal[
"argmax",
Expand Down
Loading

0 comments on commit 3e9faaa

Please sign in to comment.