Skip to content

Commit e310573

Browse files
authored
chore: run ruff (#316)
* run ruff * add init file * fixup
1 parent 4d4654b commit e310573

File tree

13 files changed

+444
-411
lines changed

13 files changed

+444
-411
lines changed

.github/workflows/mypy.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
~\AppData\Local\pip\Cache
2828
key: ${{ runner.os }}-build-${{ matrix.python-version }}
2929
- name: install-reqs
30-
run: python -m pip install --upgrade mypy==1.4.0 typing-extensions
30+
run: python -m pip install --upgrade mypy typing-extensions ruff
3131
- name: run mypy
3232
run: cd spec/API_specification && mypy dataframe_api && mypy examples
33+
- name: run ruff
34+
run: cd spec/API_specification && ruff format dataframe_api examples && ruff dataframe_api examples

spec/API_specification/dataframe_api/__init__.py

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
# mypy: disable-error-code="empty-body"
2-
"""
3-
Function stubs and API documentation for the DataFrame API standard.
4-
"""
2+
"""Function stubs and API documentation for the DataFrame API standard."""
53
from __future__ import annotations
64

7-
from typing import Dict, Sequence, Any, TYPE_CHECKING
5+
from typing import TYPE_CHECKING, Any
86

9-
from .column_object import *
7+
from .column_object import Column
108
from .dataframe_object import DataFrame
11-
from .groupby_object import *
12-
from .dtypes import *
9+
from .dtypes import (
10+
Bool,
11+
Date,
12+
Datetime,
13+
Duration,
14+
Float32,
15+
Float64,
16+
Int8,
17+
Int16,
18+
Int32,
19+
Int64,
20+
String,
21+
UInt8,
22+
UInt16,
23+
UInt32,
24+
UInt64,
25+
)
26+
from .groupby_object import Aggregation, GroupBy
1327

1428
if TYPE_CHECKING:
29+
from collections.abc import Sequence
30+
1531
from .typing import DType, Scalar
1632

1733
__all__ = [
34+
"GroupBy",
1835
"Aggregation",
1936
"Bool",
20-
"Column",
21-
"DataFrame",
2237
"Date",
2338
"Datetime",
2439
"Duration",
@@ -33,6 +48,8 @@
3348
"UInt32",
3449
"UInt64",
3550
"UInt8",
51+
"Column",
52+
"DataFrame",
3653
"__dataframe_api_version__",
3754
"column_from_1d_array",
3855
"column_from_sequence",
@@ -53,9 +70,9 @@
5370
implementation of the dataframe API standard.
5471
"""
5572

73+
5674
def concat(dataframes: Sequence[DataFrame]) -> DataFrame:
57-
"""
58-
Concatenate DataFrames vertically.
75+
"""Concatenate DataFrames vertically.
5976
6077
Parameters
6178
----------
@@ -71,9 +88,14 @@ def concat(dataframes: Sequence[DataFrame]) -> DataFrame:
7188
"""
7289
...
7390

74-
def column_from_sequence(sequence: Sequence[Any], *, dtype: DType, name: str = '') -> Column:
75-
"""
76-
Construct Column from sequence of elements.
91+
92+
def column_from_sequence(
93+
sequence: Sequence[Any],
94+
*,
95+
dtype: DType,
96+
name: str = "",
97+
) -> Column:
98+
"""Construct Column from sequence of elements.
7799
78100
Parameters
79101
----------
@@ -92,9 +114,9 @@ def column_from_sequence(sequence: Sequence[Any], *, dtype: DType, name: str = '
92114
"""
93115
...
94116

117+
95118
def dataframe_from_columns(*columns: Column) -> DataFrame:
96-
"""
97-
Construct DataFrame from sequence of Columns.
119+
"""Construct DataFrame from sequence of Columns.
98120
99121
Parameters
100122
----------
@@ -110,9 +132,8 @@ def dataframe_from_columns(*columns: Column) -> DataFrame:
110132
...
111133

112134

113-
def column_from_1d_array(array: Any, *, name: str = '') -> Column:
114-
"""
115-
Construct Column from 1D array.
135+
def column_from_1d_array(array: Any, *, name: str = "") -> Column:
136+
"""Construct Column from 1D array.
116137
117138
See `dataframe_from_2d_array` for related 2D function.
118139
@@ -148,9 +169,9 @@ def column_from_1d_array(array: Any, *, name: str = '') -> Column:
148169
"""
149170
...
150171

151-
def dataframe_from_2d_array(array: Any, *, schema: Dict[str, DType]) -> DataFrame:
152-
"""
153-
Construct DataFrame from 2D array.
172+
173+
def dataframe_from_2d_array(array: Any, *, schema: dict[str, DType]) -> DataFrame:
174+
"""Construct DataFrame from 2D array.
154175
155176
See `column_from_1d_array` for related 1D function.
156177
@@ -172,9 +193,9 @@ def dataframe_from_2d_array(array: Any, *, schema: Dict[str, DType]) -> DataFram
172193
"""
173194
...
174195

175-
class null:
176-
"""
177-
A `null` object to represent missing data.
196+
197+
class null: # noqa: N801
198+
"""A `null` object to represent missing data.
178199
179200
``null`` is a scalar, and may be used when constructing a `Column` from a
180201
Python sequence with `column_from_sequence`. It does not support ``is``,
@@ -198,11 +219,10 @@ class null:
198219
used to check if an object *is* the ``null`` object.
199220
200221
"""
201-
...
222+
202223

203224
def is_null(value: object, /) -> bool:
204-
"""
205-
Check if an object is a `null` scalar.
225+
"""Check if an object is a `null` scalar.
206226
207227
Parameters
208228
----------
@@ -217,9 +237,9 @@ def is_null(value: object, /) -> bool:
217237
"""
218238
...
219239

240+
220241
def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool:
221-
"""
222-
Returns a boolean indicating whether a provided dtype is of a specified data type “kind”.
242+
"""Indicate whether a provided dtype is of a specified data type "kind".
223243
224244
Parameters
225245
----------
@@ -233,9 +253,11 @@ def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool:
233253
234254
- 'bool': boolean data type (Bool).
235255
- 'signed integer': signed integer data types (Int8, Int16, Int32, Int64).
236-
- 'unsigned integer': unsigned integer data types (UInt8, UInt16, UInt32, UInt64).
256+
- 'unsigned integer': unsigned integer data types
257+
(UInt8, UInt16, UInt32, UInt64).
237258
- 'floating': floating-point data types (Float32, Float64).
238-
- 'integral': integer data types. Shorthand for ('signed integer', 'unsigned integer').
259+
- 'integral': integer data types. Shorthand for
260+
('signed integer', 'unsigned integer').
239261
- 'numeric': numeric data types. Shorthand for ('integral', 'floating').
240262
241263
If kind is a tuple, the tuple specifies a union of dtypes and/or kinds,
@@ -249,11 +271,12 @@ def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool:
249271
"""
250272
...
251273

274+
252275
def date(year: int, month: int, day: int) -> Scalar:
253-
"""
254-
Create date object which can be used for filtering.
276+
"""Create date object which can be used for filtering.
255277
256-
The full 32-bit signed integer range of days since epoch should be supported (between -5877641-06-23 and 5881580-07-11 inclusive).
278+
The full 32-bit signed integer range of days since epoch should be supported
279+
(between -5877641-06-23 and 5881580-07-11 inclusive).
257280
258281
Examples
259282
--------
@@ -265,4 +288,3 @@ def date(year: int, month: int, day: int) -> Scalar:
265288
... )
266289
>>> df.filter(mask)
267290
"""
268-

0 commit comments

Comments
 (0)