From 5780f2111d47cf06c4e6b5e8bfc30b4649ada2bb Mon Sep 17 00:00:00 2001 From: dangotbanned <125183946+dangotbanned@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:15:07 +0100 Subject: [PATCH] docs(typing): Remove `NonGeoDataType` and amend error message in `_data_to_csv_string` See https://github.com/vega/altair/pull/3426#issuecomment-2177601705 See https://github.com/vega/altair/issues/3441 --- altair/utils/data.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/altair/utils/data.py b/altair/utils/data.py index 2b429d760..41b5e71aa 100644 --- a/altair/utils/data.py +++ b/altair/utils/data.py @@ -44,7 +44,6 @@ class SupportsGeoInterface(Protocol): DataType = Union[dict, pd.DataFrame, SupportsGeoInterface, DataFrameLike] TDataType = TypeVar("TDataType", bound=DataType) -NonGeoDataType = Union[dict, pd.DataFrame, DataFrameLike] VegaLiteDataDict = Dict[str, Union[str, dict, List[dict]]] ToValuesReturnType = Dict[str, Union[dict, List[dict]]] @@ -263,7 +262,7 @@ def to_csv( @overload def to_csv( - data: NonGeoDataType, + data: Union[dict, pd.DataFrame, DataFrameLike], prefix: str = ..., extension: str = ..., filename: str = ..., @@ -272,7 +271,7 @@ def to_csv( def to_csv( - data: Optional[NonGeoDataType] = None, + data: Optional[Union[dict, pd.DataFrame, DataFrameLike]] = None, prefix: str = "altair-data", extension: str = "csv", filename: str = "{prefix}-{hash}.{extension}", @@ -378,8 +377,9 @@ def _data_to_csv_string(data: Union[dict, pd.DataFrame, DataFrameLike]) -> str: check_data_type(data) if isinstance(data, SupportsGeoInterface): raise NotImplementedError( - "to_csv does not work with data that " - "contains the __geo_interface__ attribute" + f"to_csv does not yet work with data that " + f"is of type {type(SupportsGeoInterface).__name__!r}.\n" + f"See https://github.com/vega/altair/issues/3441" ) elif isinstance(data, pd.DataFrame): data = sanitize_dataframe(data)