Skip to content

Commit c47b0f1

Browse files
committed
fix ruff errors
1 parent 988f05a commit c47b0f1

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

python/datafusion/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,26 @@
2121
See https://datafusion.apache.org/python for more information.
2222
"""
2323

24+
# isort: skip_file # Prevent import-sorting linter errors (I001)
25+
# ruff: noqa: I001
26+
2427
from __future__ import annotations
2528

2629
from typing import Any
2730

2831
try:
2932
import importlib.metadata as importlib_metadata
3033
except ImportError:
31-
import importlib_metadata
34+
import importlib_metadata # type: ignore[import]
3235

36+
# Public submodules
3337
from . import functions, object_store, substrait, unparser
3438

3539
# The following imports are okay to remain as opaque to the user.
3640
from ._internal import Config, EXPECTED_PROVIDER_MSG
3741
from .catalog import Catalog, Database, Table
3842
from .col import col, column
39-
from .common import (
40-
DFSchema,
41-
)
43+
from .common import DFSchema
4244
from .context import (
4345
RuntimeEnvBuilder,
4446
SessionConfig,
@@ -47,10 +49,7 @@
4749
)
4850
from .dataframe import DataFrame, ParquetColumnOptions, ParquetWriterOptions
4951
from .dataframe_formatter import configure_formatter
50-
from .expr import (
51-
Expr,
52-
WindowFrame,
53-
)
52+
from .expr import Expr, WindowFrame
5453
from .io import read_avro, read_csv, read_json, read_parquet
5554
from .plan import ExecutionPlan, LogicalPlan
5655
from .record_batch import RecordBatch, RecordBatchStream

python/datafusion/context.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@
2929

3030
import pyarrow as pa
3131

32-
from datafusion.catalog import Catalog, CatalogProvider, Table
32+
from datafusion.catalog import Catalog
3333
from datafusion.dataframe import DataFrame
34-
from datafusion.expr import SortKey, sort_list_to_raw_sort_list
34+
from datafusion.expr import sort_list_to_raw_sort_list
3535
from datafusion.record_batch import RecordBatchStream
36-
from datafusion.user_defined import AggregateUDF, ScalarUDF, TableFunction, WindowUDF
3736
from datafusion.utils import _normalize_table_provider
3837

3938
from ._internal import RuntimeEnvBuilder as RuntimeEnvBuilderInternal
@@ -50,7 +49,15 @@
5049
import polars as pl # type: ignore[import]
5150

5251
from datafusion import TableProvider
52+
from datafusion.catalog import CatalogProvider, Table
53+
from datafusion.expr import SortKey
5354
from datafusion.plan import ExecutionPlan, LogicalPlan
55+
from datafusion.user_defined import (
56+
AggregateUDF,
57+
ScalarUDF,
58+
TableFunction,
59+
WindowUDF,
60+
)
5461

5562

5663
class ArrowStreamExportable(Protocol):
@@ -735,7 +742,7 @@ def from_polars(self, data: pl.DataFrame, name: str | None = None) -> DataFrame:
735742
# https://github.com/apache/datafusion-python/pull/1016#discussion_r1983239116
736743
# is the discussion on how we arrived at adding register_view
737744
def register_view(self, name: str, df: DataFrame) -> None:
738-
"""Register a :py:class: `~datafusion.detaframe.DataFrame` as a view.
745+
"""Register a :py:class:`~datafusion.dataframe.DataFrame` as a view.
739746
740747
Args:
741748
name (str): The name to register the view under.
@@ -747,8 +754,7 @@ def register_view(self, name: str, df: DataFrame) -> None:
747754
def register_table(
748755
self, name: str, table: Table | TableProvider | TableProviderExportable
749756
) -> None:
750-
"""Register a :py:class:`~datafusion.catalog.Table` or
751-
:py:class:`~datafusion.TableProvider`.
757+
"""Register a Table or TableProvider.
752758
753759
The registered table can be referenced from SQL statements executed against
754760
this context.

python/datafusion/expr.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,24 @@
2525
import typing as _typing
2626
from typing import TYPE_CHECKING, Any, ClassVar, Iterable, Optional, Sequence
2727

28-
import pyarrow as pa
29-
3028
try:
3129
from warnings import deprecated # Python 3.13+
3230
except ImportError:
3331
from typing_extensions import deprecated # Python 3.12
3432

35-
from datafusion.common import NullTreatment
33+
import pyarrow as pa
3634

3735
from ._internal import expr as expr_internal
3836
from ._internal import functions as functions_internal
3937

4038
if TYPE_CHECKING:
4139
from collections.abc import Sequence
4240

43-
# Type-only imports
44-
from datafusion.common import DataTypeMap, RexType
41+
from datafusion.common import ( # type: ignore[import]
42+
DataTypeMap,
43+
NullTreatment,
44+
RexType,
45+
)
4546
from datafusion.plan import LogicalPlan
4647

4748

python/datafusion/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
from typing import TYPE_CHECKING
2323

2424
from datafusion.context import SessionContext
25-
from datafusion.dataframe import DataFrame
2625

2726
if TYPE_CHECKING:
2827
import pathlib
2928

3029
import pyarrow as pa
3130

31+
from datafusion.dataframe import DataFrame
3232
from datafusion.expr import Expr
3333

3434

python/datafusion/table_provider.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ def from_dataframe(cls, df: Any) -> TableProvider:
6767
"""
6868
from datafusion.dataframe import DataFrame as DataFrameWrapper
6969

70-
if isinstance(df, DataFrameWrapper):
71-
dataframe = df
72-
else:
73-
dataframe = DataFrameWrapper(df)
70+
dataframe = df if isinstance(df, DataFrameWrapper) else DataFrameWrapper(df)
7471

7572
return dataframe.into_view()
7673

python/datafusion/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def _normalize_table_provider(
6060
Raises:
6161
TypeError: If ``table`` is not a supported table provider input.
6262
"""
63-
6463
from datafusion.catalog import Table as _Table
6564
from datafusion.table_provider import TableProvider as _TableProvider
6665

0 commit comments

Comments
 (0)