diff --git a/altair/utils/data.py b/altair/utils/data.py index 8ab46a6f7..61923231c 100644 --- a/altair/utils/data.py +++ b/altair/utils/data.py @@ -14,7 +14,6 @@ TypeVar, Union, Dict, - Optional, overload, runtime_checkable, ) @@ -54,7 +53,7 @@ class SupportsGeoInterface(Protocol): str, Union[str, Dict[Any, Any], List[Dict[Any, Any]]] ] ToValuesReturnType: TypeAlias = Dict[str, Union[Dict[Any, Any], List[Dict[Any, Any]]]] -SampleReturnType = Optional[Union[pd.DataFrame, Dict[str, Sequence], "pa.lib.Table"]] +SampleReturnType = Union[pd.DataFrame, Dict[str, Sequence], "pa.lib.Table", None] def is_data_type(obj: Any) -> TypeIs[DataType]: diff --git a/pyproject.toml b/pyproject.toml index d96a5d4b1..563b8e1d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -320,6 +320,10 @@ unfixable= [ [tool.ruff.lint.mccabe] max-complexity = 18 +[tool.ruff.lint.flake8-tidy-imports.banned-api] +# https://docs.astral.sh/ruff/settings/#lint_flake8-tidy-imports_banned-api +"typing.Optional".msg = "Use `Union[T, None]` instead.\n`typing.Optional` is likely to be confused with `altair.Optional`, which have a similar but different semantic meaning.\nSee https://github.com/vega/altair/pull/3449" + [tool.ruff.format] quote-style = "double" indent-style = "space"