Skip to content

Commit ad26c8c

Browse files
committed
Working through more ruff checks and disabling a bunch for now
1 parent f8f490e commit ad26c8c

File tree

10 files changed

+62
-23
lines changed

10 files changed

+62
-23
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
autoapi_python_class_content = "both"
7474

7575

76-
def autoapi_skip_member_fn(app, what, name, obj, skip, options):
76+
def autoapi_skip_member_fn(app, what, name, obj, skip, options): # noqa: ARG001
7777
skip_contents = [
7878
# Re-exports
7979
("class", "datafusion.DataFrame"),

examples/python-udwf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, alpha: float) -> None:
5959
def supports_bounded_execution(self) -> bool:
6060
return True
6161

62-
def get_range(self, idx: int, num_rows: int) -> tuple[int, int]:
62+
def get_range(self, idx: int, num_rows: int) -> tuple[int, int]: # noqa: ARG002
6363
# Override the default range of current row since uses_window_frame is False
6464
# So for the purpose of this test we just smooth from the previous row to
6565
# current.

pyproject.toml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,42 @@ ignore = [
7979
"SLF001", # Allow accessing private members
8080
"TD002",
8181
"TD003", # Allow TODO lines
82-
"UP007" # Disallowing Union is pedantic
82+
"UP007", # Disallowing Union is pedantic
8383
# TODO: Enable all of the following, but this PR is getting too large already
84+
"PT001",
85+
"ANN101",
86+
"ANN204",
87+
"B008",
88+
"EM101",
89+
"PLR0913",
90+
"PLR1714",
91+
"ANN201",
92+
"C400",
93+
"TRY003",
94+
"B904",
95+
"UP006",
96+
"RUF012",
97+
"FBT003",
98+
"C416",
99+
"SIM102",
100+
"PGH003",
101+
"PLR2004",
102+
"PERF401",
103+
"PD901",
104+
"EM102",
105+
"ERA001",
106+
"SIM108",
107+
"ICN001",
108+
"ANN001",
109+
"ANN202",
110+
"PTH",
111+
"N812",
112+
"INP001",
113+
"DTZ007",
114+
"PLW2901",
115+
"RET503",
116+
"RUF015",
117+
"TCH001",
84118
]
85119

86120
[tool.ruff.lint.pydocstyle]
@@ -103,11 +137,12 @@ max-doc-length = 88
103137
"PT011",
104138
"RUF015",
105139
"S608",
106-
"PLR0913"
140+
"PLR0913",
141+
"PT004",
107142
]
108-
"examples/*" = ["D", "W505"]
109-
"dev/*" = ["D"]
110-
"benchmarks/*" = ["D", "F"]
143+
"examples/*" = ["D", "W505", "E501", "T201", "S101"]
144+
"dev/*" = ["D", "E", "T", "S", "PLR", "C", "SIM", "UP", "EXE", "N817"]
145+
"benchmarks/*" = ["D", "F", "T", "BLE", "FURB", "PLR", "E", "TD", "TRY", "S", "SIM", "EXE", "UP"]
111146
"docs/*" = ["D"]
112147

113148
[dependency-groups]

python/datafusion/dataframe.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
List,
3030
Literal,
3131
Optional,
32+
Type,
3233
Union,
3334
overload,
3435
)
@@ -49,10 +50,11 @@
4950
import polars as pl
5051
import pyarrow as pa
5152

53+
from datafusion._internal import DataFrame as DataFrameInternal
54+
from datafusion._internal import expr as expr_internal
55+
5256
from enum import Enum
5357

54-
from datafusion._internal import DataFrame as DataFrameInternal
55-
from datafusion._internal import expr as expr_internal
5658
from datafusion.expr import Expr, SortExpr, sort_or_default
5759

5860

@@ -73,7 +75,7 @@ class Compression(Enum):
7375
LZ4_RAW = "lz4_raw"
7476

7577
@classmethod
76-
def from_str(cls, value: str) -> Compression:
78+
def from_str(cls: Type[Compression], value: str) -> Compression:
7779
"""Convert a string to a Compression enum value.
7880
7981
Args:
@@ -88,8 +90,9 @@ def from_str(cls, value: str) -> Compression:
8890
try:
8991
return cls(value.lower())
9092
except ValueError:
93+
valid_values = str([item.value for item in Compression])
9194
raise ValueError(
92-
f"{value} is not a valid Compression. Valid values are: {[item.value for item in Compression]}"
95+
f"{value} is not a valid Compression. Valid values are: {valid_values}"
9396
)
9497

9598
def get_default_level(self) -> Optional[int]:

python/datafusion/input/location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ def build_table(
8484
raise RuntimeError(msg)
8585

8686
# Input could possibly be multiple files. Create a list if so
87-
input_files = glob.glob(input_item) # noqa: PTH207
87+
input_files = glob.glob(input_item)
8888

8989
return SqlTable(table_name, columns, num_rows, input_files)

python/datafusion/io.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from datafusion.expr import Expr
3434

3535

36-
def read_parquet( # noqa: PLR0913
36+
def read_parquet(
3737
path: str | pathlib.Path,
3838
table_partition_cols: list[tuple[str, str]] | None = None,
3939
parquet_pruning: bool = True,
@@ -81,7 +81,7 @@ def read_parquet( # noqa: PLR0913
8181
)
8282

8383

84-
def read_json( # noqa: PLR0913
84+
def read_json(
8585
path: str | pathlib.Path,
8686
schema: pa.Schema | None = None,
8787
schema_infer_max_records: int = 1000,
@@ -122,7 +122,7 @@ def read_json( # noqa: PLR0913
122122
)
123123

124124

125-
def read_csv( # noqa: PLR0913
125+
def read_csv(
126126
path: str | pathlib.Path | list[str] | list[pathlib.Path],
127127
schema: pa.Schema | None = None,
128128
has_header: bool = True,

python/datafusion/udf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ def _decorator(
202202
volatility: Volatility | str,
203203
name: Optional[str] = None,
204204
) -> Callable:
205-
def decorator(func: Callable): # noqa: ANN202
205+
def decorator(func: Callable):
206206
udf_caller = ScalarUDF.udf(
207207
func, input_types, return_type, volatility, name
208208
)
209209

210210
@functools.wraps(func)
211-
def wrapper(*args: Any, **kwargs: Any): # noqa: ANN202
211+
def wrapper(*args: Any, **kwargs: Any):
212212
return udf_caller(*args, **kwargs)
213213

214214
return wrapper
@@ -249,7 +249,7 @@ class AggregateUDF:
249249
also :py:class:`ScalarUDF` for operating on a row by row basis.
250250
"""
251251

252-
def __init__( # noqa: PLR0913
252+
def __init__(
253253
self,
254254
name: str,
255255
accumulator: Callable[[], Accumulator],
@@ -375,7 +375,7 @@ def udf4() -> Summarize:
375375
aggregation or window function calls.
376376
"""
377377

378-
def _function( # noqa: PLR0913
378+
def _function(
379379
accum: Callable[[], Accumulator],
380380
input_types: pa.DataType | list[pa.DataType],
381381
return_type: pa.DataType,

python/tests/test_aggregation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def df_aggregate_100():
8888
f.covar_samp(column("b"), column("c")),
8989
lambda a, b, c, d: np.array(np.cov(b, c, ddof=1)[0][1]),
9090
),
91-
# f.grouping(col_a), # No physical plan implemented yet # noqa: ERA001
91+
# f.grouping(col_a), # No physical plan implemented yet
9292
(f.max(column("a")), lambda a, b, c, d: np.array(np.max(a))),
9393
(f.mean(column("b")), lambda a, b, c, d: np.array(np.mean(b))),
9494
(f.median(column("b")), lambda a, b, c, d: np.array(np.median(b))),

python/tests/test_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_literal(df):
8181
literal("1"),
8282
literal("OK"),
8383
literal(3.14),
84-
literal(True), # noqa: FBT003
84+
literal(True),
8585
literal(b"hello world"),
8686
)
8787
result = df.collect()

python/tests/test_imports.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ def test_class_module_is_datafusion():
169169

170170

171171
def test_import_from_functions_submodule():
172-
from datafusion.functions import abs, sin # noqa: A004
172+
from datafusion.functions import abs as df_abs
173+
from datafusion.functions import sin
173174

174-
assert functions.abs is abs
175+
assert functions.abs is df_abs
175176
assert functions.sin is sin
176177

177178
msg = "cannot import name 'foobar' from 'datafusion.functions'"

0 commit comments

Comments
 (0)