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

refactor(ruff): Apply TC006 fixes #3706

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion altair/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion altair/utils/mimebundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions altair/utils/plugin_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions altair/vegalite/v5/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down