From 5929a5e550f8747a296c801fb1979fd59e1fa3db Mon Sep 17 00:00:00 2001 From: dangotbanned <125183946+dangotbanned@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:08:24 +0100 Subject: [PATCH] fix: Support already parsed shorthand in `FieldChannelMixin` Ensures the same output from ```py alt.Y("count()") alt.Y(alt.agg.count()) ``` --- altair/vegalite/v5/schema/channels.py | 2 +- tools/generate_schema_wrapper.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/altair/vegalite/v5/schema/channels.py b/altair/vegalite/v5/schema/channels.py index 530af95ee..0d14bc3ac 100644 --- a/altair/vegalite/v5/schema/channels.py +++ b/altair/vegalite/v5/schema/channels.py @@ -169,7 +169,7 @@ def to_dict( if shorthand is Undefined: parsed = {} - elif isinstance(shorthand, str): + elif isinstance(shorthand, (str, dict)): parsed = parse_shorthand(shorthand, data=context.get("data", None)) type_required = "type" in self._kwds # type: ignore[attr-defined] type_in_shorthand = "type" in parsed diff --git a/tools/generate_schema_wrapper.py b/tools/generate_schema_wrapper.py index 094cd66cc..27bddb525 100644 --- a/tools/generate_schema_wrapper.py +++ b/tools/generate_schema_wrapper.py @@ -99,7 +99,7 @@ def to_dict( if shorthand is Undefined: parsed = {} - elif isinstance(shorthand, str): + elif isinstance(shorthand, (str, dict)): parsed = parse_shorthand(shorthand, data=context.get("data", None)) type_required = "type" in self._kwds # type: ignore[attr-defined] type_in_shorthand = "type" in parsed