diff --git a/spec/API_specification/dataframe_api/__init__.py b/spec/API_specification/dataframe_api/__init__.py index 973a3478..b943e5c6 100644 --- a/spec/API_specification/dataframe_api/__init__.py +++ b/spec/API_specification/dataframe_api/__init__.py @@ -1,5 +1,6 @@ # mypy: disable-error-code="empty-body" """Function stubs and API documentation for the DataFrame API standard.""" + from __future__ import annotations from typing import TYPE_CHECKING, Any, Literal diff --git a/spec/API_specification/dataframe_api/column_object.py b/spec/API_specification/dataframe_api/column_object.py index e3d4e1b7..8cf20dd7 100644 --- a/spec/API_specification/dataframe_api/column_object.py +++ b/spec/API_specification/dataframe_api/column_object.py @@ -579,32 +579,23 @@ def __divmod__(self, other: Self | AnyScalar) -> tuple[Column, Column]: """ ... - def __radd__(self, other: Self | AnyScalar) -> Self: - ... + def __radd__(self, other: Self | AnyScalar) -> Self: ... - def __rsub__(self, other: Self | AnyScalar) -> Self: - ... + def __rsub__(self, other: Self | AnyScalar) -> Self: ... - def __rmul__(self, other: Self | AnyScalar) -> Self: - ... + def __rmul__(self, other: Self | AnyScalar) -> Self: ... - def __rtruediv__(self, other: Self | AnyScalar) -> Self: - ... + def __rtruediv__(self, other: Self | AnyScalar) -> Self: ... - def __rand__(self, other: Self | bool) -> Self: - ... + def __rand__(self, other: Self | bool) -> Self: ... - def __ror__(self, other: Self | bool) -> Self: - ... + def __ror__(self, other: Self | bool) -> Self: ... - def __rfloordiv__(self, other: Self | AnyScalar) -> Self: - ... + def __rfloordiv__(self, other: Self | AnyScalar) -> Self: ... - def __rpow__(self, other: Self | AnyScalar) -> Self: - ... + def __rpow__(self, other: Self | AnyScalar) -> Self: ... - def __rmod__(self, other: Self | AnyScalar) -> Self: - ... + def __rmod__(self, other: Self | AnyScalar) -> Self: ... def __invert__(self) -> Self: """Invert truthiness of (boolean) elements. diff --git a/spec/API_specification/dataframe_api/dataframe_object.py b/spec/API_specification/dataframe_api/dataframe_object.py index 33c04443..c1421a2b 100644 --- a/spec/API_specification/dataframe_api/dataframe_object.py +++ b/spec/API_specification/dataframe_api/dataframe_object.py @@ -576,32 +576,23 @@ def __divmod__(self, other: AnyScalar) -> tuple[DataFrame, DataFrame]: """ ... - def __radd__(self, other: AnyScalar) -> Self: - ... + def __radd__(self, other: AnyScalar) -> Self: ... - def __rsub__(self, other: AnyScalar) -> Self: - ... + def __rsub__(self, other: AnyScalar) -> Self: ... - def __rmul__(self, other: AnyScalar) -> Self: - ... + def __rmul__(self, other: AnyScalar) -> Self: ... - def __rtruediv__(self, other: AnyScalar) -> Self: - ... + def __rtruediv__(self, other: AnyScalar) -> Self: ... - def __rand__(self, other: AnyScalar) -> Self: - ... + def __rand__(self, other: AnyScalar) -> Self: ... - def __ror__(self, other: AnyScalar) -> Self: - ... + def __ror__(self, other: AnyScalar) -> Self: ... - def __rfloordiv__(self, other: AnyScalar) -> Self: - ... + def __rfloordiv__(self, other: AnyScalar) -> Self: ... - def __rpow__(self, other: AnyScalar) -> Self: - ... + def __rpow__(self, other: AnyScalar) -> Self: ... - def __rmod__(self, other: AnyScalar) -> Self: - ... + def __rmod__(self, other: AnyScalar) -> Self: ... def __invert__(self) -> Self: """Invert truthiness of (boolean) elements. diff --git a/spec/API_specification/dataframe_api/groupby_object.py b/spec/API_specification/dataframe_api/groupby_object.py index 7eb17088..1b959d18 100644 --- a/spec/API_specification/dataframe_api/groupby_object.py +++ b/spec/API_specification/dataframe_api/groupby_object.py @@ -23,48 +23,37 @@ class GroupBy(Protocol): """ - def any(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def any(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... - def all(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def all(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... - def min(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def min(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... - def max(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def max(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... - def sum(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def sum(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... - def prod(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def prod(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... - def median(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def median(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... - def mean(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: - ... + def mean(self, *, skip_nulls: bool | Scalar = True) -> DataFrame: ... def std( self, *, correction: float | Scalar = 1, skip_nulls: bool | Scalar = True, - ) -> DataFrame: - ... + ) -> DataFrame: ... def var( self, *, correction: float | Scalar = 1, skip_nulls: bool | Scalar = True, - ) -> DataFrame: - ... + ) -> DataFrame: ... - def size(self) -> DataFrame: - ... + def size(self) -> DataFrame: ... def aggregate(self, *aggregation: Aggregation) -> DataFrame: """Aggregate columns according to given aggregation function. @@ -93,36 +82,28 @@ def rename(self, name: str | Scalar) -> Aggregation: ... @classmethod - def any(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def any(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod - def all(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def all(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod - def min(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def min(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod - def max(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def max(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod - def sum(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def sum(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod - def prod(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def prod(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod - def median(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def median(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod - def mean(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: - ... + def mean(cls, column: str, *, skip_nulls: bool | Scalar = True) -> Aggregation: ... @classmethod def std( @@ -131,8 +112,7 @@ def std( *, correction: float | Scalar = 1, skip_nulls: bool | Scalar = True, - ) -> Aggregation: - ... + ) -> Aggregation: ... @classmethod def var( @@ -141,9 +121,7 @@ def var( *, correction: float | Scalar = 1, skip_nulls: bool | Scalar = True, - ) -> Aggregation: - ... + ) -> Aggregation: ... @classmethod - def size(cls) -> Aggregation: - ... + def size(cls) -> Aggregation: ... diff --git a/spec/API_specification/dataframe_api/scalar_object.py b/spec/API_specification/dataframe_api/scalar_object.py index 32ac3c8a..5df35c42 100644 --- a/spec/API_specification/dataframe_api/scalar_object.py +++ b/spec/API_specification/dataframe_api/scalar_object.py @@ -70,11 +70,9 @@ def scalar(self) -> Any: """Return underlying (not-necessarily-Standard-compliant) scalar object.""" ... - def __lt__(self, other: AnyScalar) -> Scalar: - ... + def __lt__(self, other: AnyScalar) -> Scalar: ... - def __le__(self, other: AnyScalar) -> Scalar: - ... + def __le__(self, other: AnyScalar) -> Scalar: ... def __eq__(self, other: AnyScalar) -> Scalar: # type: ignore[override] ... @@ -82,61 +80,44 @@ def __eq__(self, other: AnyScalar) -> Scalar: # type: ignore[override] def __ne__(self, other: AnyScalar) -> Scalar: # type: ignore[override] ... - def __gt__(self, other: AnyScalar) -> Scalar: - ... + def __gt__(self, other: AnyScalar) -> Scalar: ... - def __ge__(self, other: AnyScalar) -> Scalar: - ... + def __ge__(self, other: AnyScalar) -> Scalar: ... - def __add__(self, other: AnyScalar) -> Scalar: - ... + def __add__(self, other: AnyScalar) -> Scalar: ... - def __radd__(self, other: AnyScalar) -> Scalar: - ... + def __radd__(self, other: AnyScalar) -> Scalar: ... - def __sub__(self, other: AnyScalar) -> Scalar: - ... + def __sub__(self, other: AnyScalar) -> Scalar: ... - def __rsub__(self, other: AnyScalar) -> Scalar: - ... + def __rsub__(self, other: AnyScalar) -> Scalar: ... - def __mul__(self, other: AnyScalar) -> Scalar: - ... + def __mul__(self, other: AnyScalar) -> Scalar: ... - def __rmul__(self, other: AnyScalar) -> Scalar: - ... + def __rmul__(self, other: AnyScalar) -> Scalar: ... - def __mod__(self, other: AnyScalar) -> Scalar: - ... + def __mod__(self, other: AnyScalar) -> Scalar: ... # Signatures of "__rmod__" of "Scalar" and "__mod__" of "str | int | float | Scalar" # are unsafely overlapping def __rmod__(self, other: AnyScalar) -> Scalar: # type: ignore[misc] ... - def __pow__(self, other: AnyScalar) -> Scalar: - ... + def __pow__(self, other: AnyScalar) -> Scalar: ... - def __rpow__(self, other: AnyScalar) -> Scalar: - ... + def __rpow__(self, other: AnyScalar) -> Scalar: ... - def __floordiv__(self, other: AnyScalar) -> Scalar: - ... + def __floordiv__(self, other: AnyScalar) -> Scalar: ... - def __rfloordiv__(self, other: AnyScalar) -> Scalar: - ... + def __rfloordiv__(self, other: AnyScalar) -> Scalar: ... - def __truediv__(self, other: AnyScalar) -> Scalar: - ... + def __truediv__(self, other: AnyScalar) -> Scalar: ... - def __rtruediv__(self, other: AnyScalar) -> Scalar: - ... + def __rtruediv__(self, other: AnyScalar) -> Scalar: ... - def __neg__(self) -> Scalar: - ... + def __neg__(self) -> Scalar: ... - def __abs__(self) -> Scalar: - ... + def __abs__(self) -> Scalar: ... def __bool__(self) -> bool: """Note that this return a Python scalar. diff --git a/spec/API_specification/dataframe_api/typing.py b/spec/API_specification/dataframe_api/typing.py index 5ed321eb..bb94fe1c 100644 --- a/spec/API_specification/dataframe_api/typing.py +++ b/spec/API_specification/dataframe_api/typing.py @@ -1,4 +1,5 @@ """Types for type annotations used in the dataframe API standard.""" + from __future__ import annotations from typing import ( @@ -27,44 +28,31 @@ class Namespace(Protocol): __dataframe_api_version__: str - class Int64: - ... + class Int64: ... - class Int32: - ... + class Int32: ... - class Int16: - ... + class Int16: ... - class Int8: - ... + class Int8: ... - class UInt64: - ... + class UInt64: ... - class UInt32: - ... + class UInt32: ... - class UInt16: - ... + class UInt16: ... - class UInt8: - ... + class UInt8: ... - class Float64: - ... + class Float64: ... - class Float32: - ... + class Float32: ... - class Bool: - ... + class Bool: ... - class Date: - ... + class Date: ... - class NullType: - ... + class NullType: ... null: NullType @@ -76,8 +64,7 @@ def __init__( # noqa: ANN204 self, time_unit: Literal["ms", "us"], time_zone: str | None = None, - ): - ... + ): ... class Duration: time_unit: Literal["ms", "us"] @@ -85,16 +72,13 @@ class Duration: def __init__( # noqa: ANN204 self, time_unit: Literal["ms", "us"], - ): - ... + ): ... - class String: - ... + class String: ... Aggregation: AggregationT - def concat(self, dataframes: Sequence[DataFrame]) -> DataFrame: - ... + def concat(self, dataframes: Sequence[DataFrame]) -> DataFrame: ... def column_from_sequence( self, @@ -102,11 +86,9 @@ def column_from_sequence( *, dtype: DType, name: str = "", - ) -> Column: - ... + ) -> Column: ... - def dataframe_from_columns(self, *columns: Column) -> DataFrame: - ... + def dataframe_from_columns(self, *columns: Column) -> DataFrame: ... def column_from_1d_array( self, @@ -114,54 +96,45 @@ def column_from_1d_array( *, dtype: DType, name: str = "", - ) -> Column: - ... + ) -> Column: ... def dataframe_from_2d_array( self, array: Any, *, names: Sequence[str], - ) -> DataFrame: - ... + ) -> DataFrame: ... - def is_null(self, value: object, /) -> bool: - ... + def is_null(self, value: object, /) -> bool: ... - def is_dtype(self, dtype: DType, kind: str | tuple[str, ...]) -> bool: - ... + def is_dtype(self, dtype: DType, kind: str | tuple[str, ...]) -> bool: ... - def date(self, year: int, month: int, day: int) -> Scalar: - ... + def date(self, year: int, month: int, day: int) -> Scalar: ... def any_horizontal( self, *columns: Column, skip_nulls: bool = True, - ) -> Column: - ... + ) -> Column: ... def all_horizontal( self, *columns: Column, skip_nulls: bool = True, - ) -> Column: - ... + ) -> Column: ... def sorted_indices( self, *columns: Column, ascending: Sequence[bool] | bool = True, nulls_position: Literal["first", "last"] = "last", - ) -> Column: - ... + ) -> Column: ... def unique_indices( self, *columns: Column, skip_nulls: bool = True, - ) -> Column: - ... + ) -> Column: ... DType = Union[ @@ -188,8 +161,7 @@ def __dataframe_consortium_standard__( self, *, api_version: str, - ) -> DataFrame: - ... + ) -> DataFrame: ... class SupportsColumnAPI(Protocol): @@ -197,8 +169,7 @@ def __column_consortium_standard__( self, *, api_version: str, - ) -> Column: - ... + ) -> Column: ... PythonScalar = Union[str, int, float, bool] diff --git a/spec/API_specification/examples/03_working_with_nulls.py b/spec/API_specification/examples/03_working_with_nulls.py index d1002e07..d0320572 100644 --- a/spec/API_specification/examples/03_working_with_nulls.py +++ b/spec/API_specification/examples/03_working_with_nulls.py @@ -1,4 +1,5 @@ """Fill a column's NaN values with the implemenation's null value.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/spec/API_specification/examples/06_horizontal_functions.py b/spec/API_specification/examples/06_horizontal_functions.py index e6b334bc..142f2cca 100644 --- a/spec/API_specification/examples/06_horizontal_functions.py +++ b/spec/API_specification/examples/06_horizontal_functions.py @@ -11,6 +11,7 @@ namespace object, and then calling the function on the namespace object and passing an iterable of ``Column``s as input. """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/spec/API_specification/examples/07_sklearn_like_pipeline.py b/spec/API_specification/examples/07_sklearn_like_pipeline.py index 6dc60c74..1f8f5d76 100644 --- a/spec/API_specification/examples/07_sklearn_like_pipeline.py +++ b/spec/API_specification/examples/07_sklearn_like_pipeline.py @@ -10,6 +10,7 @@ `transform`. The logic within the `transform` methods is "traced" lazily and the resulting lazy object is then exported to ONNX. """ + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/spec/API_specification/examples/tpch/q5.py b/spec/API_specification/examples/tpch/q5.py index 1b8c1ba4..1ba5b898 100644 --- a/spec/API_specification/examples/tpch/q5.py +++ b/spec/API_specification/examples/tpch/q5.py @@ -16,6 +16,7 @@ GROUP BY n_name ORDER BY revenue DESC """ + from __future__ import annotations from typing import TYPE_CHECKING