Skip to content

Commit 4e26018

Browse files
committed
more ruff formatting suggestions
1 parent 58f6021 commit 4e26018

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ ignore = [
7171
"ANN401", # Allow Any for wrapper classes
7272
"COM812", # Recommended to ignore these rules when using with ruff-format
7373
"ISC001", # Recommended to ignore these rules when using with ruff-format
74+
"SLF001", # Allow accessing private members
7475
"TD002",
7576
"UP007" # Disallowing Union is pedantic
7677
]

python/datafusion/io.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,28 @@
1919

2020
from __future__ import annotations
2121

22-
import pathlib
23-
24-
import pyarrow
22+
from typing import TYPE_CHECKING
2523

2624
from datafusion.dataframe import DataFrame
27-
from datafusion.expr import Expr
2825

2926
from ._internal import SessionContext as SessionContextInternal
3027

28+
if TYPE_CHECKING:
29+
import pathlib
30+
31+
import pyarrow as pa
32+
33+
from datafusion.expr import Expr
34+
3135

32-
def read_parquet(
36+
def read_parquet( # noqa: PLR0913
3337
path: str | pathlib.Path,
38+
*,
3439
table_partition_cols: list[tuple[str, str]] | None = None,
3540
parquet_pruning: bool = True,
3641
file_extension: str = ".parquet",
3742
skip_metadata: bool = True,
38-
schema: pyarrow.Schema | None = None,
43+
schema: pa.Schema | None = None,
3944
file_sort_order: list[list[Expr]] | None = None,
4045
) -> DataFrame:
4146
"""Read a Parquet source into a :py:class:`~datafusion.dataframe.Dataframe`.
@@ -77,9 +82,10 @@ def read_parquet(
7782
)
7883

7984

80-
def read_json(
85+
def read_json( # noqa: PLR0913
8186
path: str | pathlib.Path,
82-
schema: pyarrow.Schema | None = None,
87+
*,
88+
schema: pa.Schema | None = None,
8389
schema_infer_max_records: int = 1000,
8490
file_extension: str = ".json",
8591
table_partition_cols: list[tuple[str, str]] | None = None,
@@ -118,9 +124,10 @@ def read_json(
118124
)
119125

120126

121-
def read_csv(
127+
def read_csv( # noqa: PLR0913
122128
path: str | pathlib.Path | list[str] | list[pathlib.Path],
123-
schema: pyarrow.Schema | None = None,
129+
*,
130+
schema: pa.Schema | None = None,
124131
has_header: bool = True,
125132
delimiter: str = ",",
126133
schema_infer_max_records: int = 1000,
@@ -173,7 +180,7 @@ def read_csv(
173180

174181
def read_avro(
175182
path: str | pathlib.Path,
176-
schema: pyarrow.Schema | None = None,
183+
schema: pa.Schema | None = None,
177184
file_partition_cols: list[tuple[str, str]] | None = None,
178185
file_extension: str = ".avro",
179186
) -> DataFrame:

python/datafusion/plan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from __future__ import annotations
2121

22-
from typing import TYPE_CHECKING, Any, List
22+
from typing import TYPE_CHECKING, Any
2323

2424
import datafusion._internal as df_internal
2525

@@ -54,7 +54,7 @@ def to_variant(self) -> Any:
5454
"""Convert the logical plan into its specific variant."""
5555
return self._raw_plan.to_variant()
5656

57-
def inputs(self) -> List[LogicalPlan]:
57+
def inputs(self) -> list[LogicalPlan]:
5858
"""Returns the list of inputs to the logical plan."""
5959
return [LogicalPlan(p) for p in self._raw_plan.inputs()]
6060

@@ -106,7 +106,7 @@ def __init__(self, plan: df_internal.ExecutionPlan) -> None:
106106
"""This constructor should not be called by the end user."""
107107
self._raw_plan = plan
108108

109-
def children(self) -> List[ExecutionPlan]:
109+
def children(self) -> list[ExecutionPlan]:
110110
"""Get a list of children `ExecutionPlan` that act as inputs to this plan.
111111
112112
The returned list will be empty for leaf nodes such as scans, will contain a

python/datafusion/record_batch.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
from typing import TYPE_CHECKING
2727

2828
if TYPE_CHECKING:
29-
import pyarrow
29+
import pyarrow as pa
3030
import typing_extensions
3131

3232
import datafusion._internal as df_internal
3333

3434

3535
class RecordBatch:
36-
"""This class is essentially a wrapper for :py:class:`pyarrow.RecordBatch`."""
36+
"""This class is essentially a wrapper for :py:class:`pa.RecordBatch`."""
3737

3838
def __init__(self, record_batch: df_internal.RecordBatch) -> None:
3939
"""This constructor is generally not called by the end user.
@@ -42,8 +42,8 @@ def __init__(self, record_batch: df_internal.RecordBatch) -> None:
4242
"""
4343
self.record_batch = record_batch
4444

45-
def to_pyarrow(self) -> pyarrow.RecordBatch:
46-
"""Convert to :py:class:`pyarrow.RecordBatch`."""
45+
def to_pyarrow(self) -> pa.RecordBatch:
46+
"""Convert to :py:class:`pa.RecordBatch`."""
4747
return self.record_batch.to_pyarrow()
4848

4949

python/datafusion/substrait.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
from __future__ import annotations
2525

26-
import pathlib
2726
from typing import TYPE_CHECKING
2827

2928
try:
@@ -36,6 +35,8 @@
3635
from ._internal import substrait as substrait_internal
3736

3837
if TYPE_CHECKING:
38+
import pathlib
39+
3940
from datafusion.context import SessionContext
4041

4142
__all__ = [
@@ -68,7 +69,7 @@ def encode(self) -> bytes:
6869

6970

7071
@deprecated("Use `Plan` instead.")
71-
class plan(Plan):
72+
class plan(Plan): # noqa: N801
7273
"""See `Plan`."""
7374

7475

@@ -138,7 +139,7 @@ def deserialize_bytes(proto_bytes: bytes) -> Plan:
138139

139140

140141
@deprecated("Use `Serde` instead.")
141-
class serde(Serde):
142+
class serde(Serde): # noqa: N801
142143
"""See `Serde` instead."""
143144

144145

@@ -164,7 +165,7 @@ def to_substrait_plan(logical_plan: LogicalPlan, ctx: SessionContext) -> Plan:
164165

165166

166167
@deprecated("Use `Producer` instead.")
167-
class producer(Producer):
168+
class producer(Producer): # noqa: N801
168169
"""Use `Producer` instead."""
169170

170171

@@ -188,5 +189,5 @@ def from_substrait_plan(ctx: SessionContext, plan: Plan) -> LogicalPlan:
188189

189190

190191
@deprecated("Use `Consumer` instead.")
191-
class consumer(Consumer):
192+
class consumer(Consumer): # noqa: N801
192193
"""Use `Consumer` instead."""

python/datafusion/udf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,12 @@ def evaluate_all_with_rank( # noqa: B027
575575
The user must implement this method if ``include_rank`` returns True.
576576
"""
577577

578+
@abstractmethod
578579
def supports_bounded_execution(self) -> bool:
579580
"""Can the window function be incrementally computed using bounded memory?"""
580581
return False
581582

583+
@abstractmethod
582584
def uses_window_frame(self) -> bool:
583585
"""Does the window function use the values from the window frame?"""
584586
return False

0 commit comments

Comments
 (0)