Skip to content

Commit f1e0049

Browse files
authored
ci: bump narwhals>=1.27.1 (#3807)
1 parent f61a22e commit f1e0049

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

altair/utils/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
from altair.utils._dfi_types import DataFrame as DfiDataFrame
3939
from altair.vegalite.v5.schema._typing import StandardType_T as InferredVegaLiteType
4040

41+
_PandasDataFrameT = TypeVar("_PandasDataFrameT", bound="pd.DataFrame")
42+
4143
TIntoDataFrame = TypeVar("TIntoDataFrame", bound=IntoDataFrame)
4244
T = TypeVar("T")
4345
P = ParamSpec("P")
@@ -328,7 +330,7 @@ def numpy_is_subtype(dtype: Any, subtype: Any) -> bool:
328330
return False
329331

330332

331-
def sanitize_pandas_dataframe(df: pd.DataFrame) -> pd.DataFrame: # noqa: C901
333+
def sanitize_pandas_dataframe(df: _PandasDataFrameT) -> _PandasDataFrameT: # noqa: C901
332334
"""
333335
Sanitize a DataFrame to prepare it for serialization.
334336
@@ -351,7 +353,7 @@ def sanitize_pandas_dataframe(df: pd.DataFrame) -> pd.DataFrame: # noqa: C901
351353
import numpy as np
352354
import pandas as pd
353355

354-
df = df.copy()
356+
df = cast("_PandasDataFrameT", df.copy())
355357

356358
if isinstance(df.columns, pd.RangeIndex):
357359
df.columns = df.columns.astype(str)

altair/utils/data.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,20 +350,16 @@ def _compute_data_hash(data_str: str) -> str:
350350
return hashlib.sha256(data_str.encode()).hexdigest()[:32]
351351

352352

353-
def _from_geo_interface(data: SupportsGeoInterface | Any) -> dict[str, Any]:
353+
def _from_geo_interface(data: SupportsGeoInterface) -> dict[str, Any]:
354354
"""
355355
Santize a ``__geo_interface__`` w/ pre-santize step for ``pandas`` if needed.
356356
357-
Notes
358-
-----
359-
Split out to resolve typing issues related to:
360-
- Intersection types
361-
- ``typing.TypeGuard``
362-
- ``pd.DataFrame.__getattr__``
357+
Introduces an intersection type::
358+
359+
geo: <subclass of SupportsGeoInterface and DataFrame> | SupportsGeoInterface
363360
"""
364-
if is_pandas_dataframe(data):
365-
data = sanitize_pandas_dataframe(data)
366-
return sanitize_geo_interface(data.__geo_interface__)
361+
geo = sanitize_pandas_dataframe(data) if is_pandas_dataframe(data) else data
362+
return sanitize_geo_interface(geo.__geo_interface__)
367363

368364

369365
def _data_to_json_string(data: DataType) -> str:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies = [
2020
# If you update the minimum required jsonschema version, also update it in build.yml
2121
"jsonschema>=3.0",
2222
"packaging",
23-
"narwhals>=1.26.0"
23+
"narwhals>=1.27.1"
2424
]
2525
description = "Vega-Altair: A declarative statistical visualization library for Python."
2626
readme = "README.md"

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)