From 119827abd994b9011ce2af4766d5695aa5dd4ba6 Mon Sep 17 00:00:00 2001 From: dangotbanned <125183946+dangotbanned@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:45:34 +0000 Subject: [PATCH] refactor(ruff): Apply `TC006` fixes Related https://github.com/astral-sh/ruff/issues/14676, https://github.com/astral-sh/ruff/releases/tag/0.8.1 --- altair/utils/core.py | 2 +- altair/utils/mimebundle.py | 2 +- altair/utils/plugin_registry.py | 4 ++-- altair/vegalite/v5/api.py | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/altair/utils/core.py b/altair/utils/core.py index 1cac486b6..66a559fad 100644 --- a/altair/utils/core.py +++ b/altair/utils/core.py @@ -383,7 +383,7 @@ def to_list_if_array(val): # We know that the column names are strings from the isinstance check # further above but mypy thinks it is of type Hashable and therefore does not # let us assign it to the col_name variable which is already of type str. - col_name = cast(str, dtype_item[0]) + col_name = cast("str", dtype_item[0]) dtype = dtype_item[1] dtype_name = str(dtype) if dtype_name == "category": diff --git a/altair/utils/mimebundle.py b/altair/utils/mimebundle.py index 575b3f71c..56cd05a7e 100644 --- a/altair/utils/mimebundle.py +++ b/altair/utils/mimebundle.py @@ -140,7 +140,7 @@ def spec_to_mimebundle( if format in {"png", "svg", "pdf", "vega"}: return _spec_to_mimebundle_with_engine( spec, - cast(Literal["png", "svg", "pdf", "vega"], format), + cast("Literal['png', 'svg', 'pdf', 'vega']", format), internal_mode, engine=engine, format_locale=embed_options.get("formatLocale", None), diff --git a/altair/utils/plugin_registry.py b/altair/utils/plugin_registry.py index 81e34cb8d..91e9462eb 100644 --- a/altair/utils/plugin_registry.py +++ b/altair/utils/plugin_registry.py @@ -134,7 +134,7 @@ def __init__( f"https://docs.astral.sh/ruff/rules/assert/" ) deprecated_warn(msg, version="5.4.0") - self.plugin_type = cast(IsPlugin, _is_type(plugin_type)) + self.plugin_type = cast("IsPlugin", _is_type(plugin_type)) else: self.plugin_type = plugin_type self._active: Plugin[R] | None = None @@ -214,7 +214,7 @@ def _enable(self, name: str, **options) -> None: raise ValueError(self.entrypoint_err_messages[name]) from err else: raise NoSuchEntryPoint(self.entry_point_group, name) from err - value = cast(PluginT, ep.load()) + value = cast("PluginT", ep.load()) self.register(name, value) self._active_name = name self._active = self._plugins[name] diff --git a/altair/vegalite/v5/api.py b/altair/vegalite/v5/api.py index 909ed621e..5b3d93f86 100644 --- a/altair/vegalite/v5/api.py +++ b/altair/vegalite/v5/api.py @@ -798,7 +798,7 @@ def _parse_when_compose( if constraints: iters.append(_parse_when_constraints(constraints)) r = functools.reduce(operator.and_, itertools.chain.from_iterable(iters)) - return t.cast(_expr_core.BinaryExpression, r) + return t.cast("_expr_core.BinaryExpression", r) def _parse_when( @@ -1107,7 +1107,7 @@ def when( conditions = self.to_dict() current = conditions["condition"] if isinstance(current, list): - conditions = t.cast(_Conditional[_Conditions], conditions) + conditions = t.cast("_Conditional[_Conditions]", conditions) return ChainedWhen(condition, conditions) elif isinstance(current, dict): cond = _reveal_parsed_shorthand(current) @@ -1384,7 +1384,7 @@ def param( parameter.empty = empty elif empty in empty_remap: utils.deprecated_warn(warn_msg, version="5.0.0") - parameter.empty = empty_remap[t.cast(str, empty)] + parameter.empty = empty_remap[t.cast("str", empty)] else: raise ValueError(warn_msg) @@ -3086,7 +3086,7 @@ def transform_filter( verbose_composition = chart.transform_filter((datum.year == 2000) & (datum.sex == 1)) chart.transform_filter(year=2000, sex=1) """ - if depr_filter := t.cast(Any, constraints.pop("filter", None)): + if depr_filter := t.cast("Any", constraints.pop("filter", None)): utils.deprecated_warn( "Passing `filter` as a keyword is ambiguous.\n\n" "Use a positional argument for `<5.5.0` behavior.\n" @@ -3986,7 +3986,7 @@ def from_dict( pass # As a last resort, try using the Root vegalite object - return t.cast(_TSchemaBase, core.Root.from_dict(dct, validate)) + return t.cast("_TSchemaBase", core.Root.from_dict(dct, validate)) def to_dict( self,