From 217939c580e7d93df4aaba9d3c44ed496f8d0865 Mon Sep 17 00:00:00 2001 From: Stefan Binder Date: Sat, 23 Dec 2023 18:01:08 +0100 Subject: [PATCH] Specify explicit signature for __dataframe__. Remove DataFrame.version as Pyright doesn't like that in Polars it is specified as a property which is semantically not the same as an attribute (the later can be set, properties are read-only by default) --- altair/utils/_dfi_types.py | 4 +--- altair/utils/core.py | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/altair/utils/_dfi_types.py b/altair/utils/_dfi_types.py index 81f1742ba..a86414167 100644 --- a/altair/utils/_dfi_types.py +++ b/altair/utils/_dfi_types.py @@ -5,7 +5,7 @@ # # These classes are only for use in type signatures import enum -from typing import Any, Iterable, Optional, Tuple, Protocol +from typing import Any, Iterable, Optional, Tuple, Protocol, Literal class DtypeKind(enum.IntEnum): @@ -121,8 +121,6 @@ class DataFrame(Protocol): to the dataframe interchange protocol specification. """ - version: int = 0 # version of the protocol - def __dataframe__( self, nan_as_null: bool = False, allow_copy: bool = True ) -> "DataFrame": diff --git a/altair/utils/core.py b/altair/utils/core.py index ea8abf1f1..f6fec3801 100644 --- a/altair/utils/core.py +++ b/altair/utils/core.py @@ -46,7 +46,9 @@ class DataFrameLike(Protocol): - def __dataframe__(self, *args, **kwargs) -> DfiDataFrame: + def __dataframe__( + self, nan_as_null: bool = False, allow_copy: bool = True + ) -> DfiDataFrame: ...