Skip to content

Commit 5306d1e

Browse files
committed
Ruff auto fix
1 parent 99dcb4f commit 5306d1e

File tree

17 files changed

+109
-131
lines changed

17 files changed

+109
-131
lines changed

benchmarks/tpch/tpch.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ def bench(data_path, query_path):
5959
end = time.time()
6060
time_millis = (end - start) * 1000
6161
total_time_millis += time_millis
62-
print("setup,{}".format(round(time_millis, 1)))
63-
results.write("setup,{}\n".format(round(time_millis, 1)))
62+
print(f"setup,{round(time_millis, 1)}")
63+
results.write(f"setup,{round(time_millis, 1)}\n")
6464
results.flush()
6565

6666
# run queries
6767
for query in range(1, 23):
68-
with open("{}/q{}.sql".format(query_path, query)) as f:
68+
with open(f"{query_path}/q{query}.sql") as f:
6969
text = f.read()
7070
tmp = text.split(";")
7171
queries = []
@@ -83,14 +83,14 @@ def bench(data_path, query_path):
8383
end = time.time()
8484
time_millis = (end - start) * 1000
8585
total_time_millis += time_millis
86-
print("q{},{}".format(query, round(time_millis, 1)))
87-
results.write("q{},{}\n".format(query, round(time_millis, 1)))
86+
print(f"q{query},{round(time_millis, 1)}")
87+
results.write(f"q{query},{round(time_millis, 1)}\n")
8888
results.flush()
8989
except Exception as e:
9090
print("query", query, "failed", e)
9191

92-
print("total,{}".format(round(total_time_millis, 1)))
93-
results.write("total,{}\n".format(round(total_time_millis, 1)))
92+
print(f"total,{round(total_time_millis, 1)}")
93+
results.write(f"total,{round(total_time_millis, 1)}\n")
9494

9595

9696
if __name__ == "__main__":

dev/release/check-rat-report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
exclude_globs_filename = sys.argv[1]
3030
xml_filename = sys.argv[2]
3131

32-
globs = [line.strip() for line in open(exclude_globs_filename, "r")]
32+
globs = [line.strip() for line in open(exclude_globs_filename)]
3333

3434
tree = ET.parse(xml_filename)
3535
root = tree.getroot()

dev/release/generate-changelog.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@
2626

2727
def print_pulls(repo_name, title, pulls):
2828
if len(pulls) > 0:
29-
print("**{}:**".format(title))
29+
print(f"**{title}:**")
3030
print()
3131
for pull, commit in pulls:
32-
url = "https://github.com/{}/pull/{}".format(repo_name, pull.number)
32+
url = f"https://github.com/{repo_name}/pull/{pull.number}"
3333
print(
34-
"- {} [#{}]({}) ({})".format(
35-
pull.title, pull.number, url, commit.author.login
36-
)
34+
f"- {pull.title} [#{pull.number}]({url}) ({commit.author.login})"
3735
)
3836
print()
3937

examples/tpch/_tests.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,25 @@
2727
def df_selection(col_name, col_type):
2828
if col_type == pa.float64() or isinstance(col_type, pa.Decimal128Type):
2929
return F.round(col(col_name), lit(2)).alias(col_name)
30-
elif col_type == pa.string() or col_type == pa.string_view():
30+
if col_type == pa.string() or col_type == pa.string_view():
3131
return F.trim(col(col_name)).alias(col_name)
32-
else:
33-
return col(col_name)
32+
return col(col_name)
3433

3534

3635
def load_schema(col_name, col_type):
3736
if col_type == pa.int64() or col_type == pa.int32():
3837
return col_name, pa.string()
39-
elif isinstance(col_type, pa.Decimal128Type):
38+
if isinstance(col_type, pa.Decimal128Type):
4039
return col_name, pa.float64()
41-
else:
42-
return col_name, col_type
40+
return col_name, col_type
4341

4442

4543
def expected_selection(col_name, col_type):
4644
if col_type == pa.int64() or col_type == pa.int32():
4745
return F.trim(col(col_name)).cast(col_type).alias(col_name)
48-
elif col_type == pa.string() or col_type == pa.string_view():
46+
if col_type == pa.string() or col_type == pa.string_view():
4947
return F.trim(col(col_name)).alias(col_name)
50-
else:
51-
return col(col_name)
48+
return col(col_name)
5249

5350

5451
def selections_and_schema(original_schema):

python/datafusion/__init__.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,38 @@
5454

5555
__all__ = [
5656
"Accumulator",
57+
"AggregateUDF",
58+
"Catalog",
5759
"Config",
58-
"DataFrame",
59-
"SessionContext",
60-
"SessionConfig",
61-
"SQLOptions",
62-
"RuntimeEnvBuilder",
63-
"Expr",
64-
"ScalarUDF",
65-
"WindowFrame",
66-
"column",
67-
"col",
68-
"literal",
69-
"lit",
7060
"DFSchema",
71-
"Catalog",
61+
"DataFrame",
7262
"Database",
73-
"Table",
74-
"AggregateUDF",
75-
"WindowUDF",
76-
"LogicalPlan",
7763
"ExecutionPlan",
64+
"Expr",
65+
"LogicalPlan",
7866
"RecordBatch",
7967
"RecordBatchStream",
68+
"RuntimeEnvBuilder",
69+
"SQLOptions",
70+
"ScalarUDF",
71+
"SessionConfig",
72+
"SessionContext",
73+
"Table",
74+
"WindowFrame",
75+
"WindowUDF",
76+
"col",
77+
"column",
8078
"common",
8179
"expr",
8280
"functions",
81+
"lit",
82+
"literal",
8383
"object_store",
84-
"substrait",
85-
"read_parquet",
8684
"read_avro",
8785
"read_csv",
8886
"read_json",
87+
"read_parquet",
88+
"substrait",
8989
]
9090

9191

python/datafusion/common.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
"DFSchema",
3939
"DataType",
4040
"DataTypeMap",
41-
"RexType",
42-
"PythonType",
43-
"SqlType",
4441
"NullTreatment",
45-
"SqlTable",
42+
"PythonType",
43+
"RexType",
44+
"SqlFunction",
4645
"SqlSchema",
47-
"SqlView",
4846
"SqlStatistics",
49-
"SqlFunction",
47+
"SqlTable",
48+
"SqlType",
49+
"SqlView",
5050
]
5151

5252

python/datafusion/context.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ def with_temp_file_path(self, path: str | pathlib.Path) -> RuntimeEnvBuilder:
393393
class RuntimeConfig(RuntimeEnvBuilder):
394394
"""See `RuntimeEnvBuilder`."""
395395

396-
pass
397396

398397

399398
class SQLOptions:
@@ -498,7 +497,7 @@ def __init__(
498497

499498
self.ctx = SessionContextInternal(config, runtime)
500499

501-
def enable_url_table(self) -> "SessionContext":
500+
def enable_url_table(self) -> SessionContext:
502501
"""Control if local files can be queried as tables.
503502
504503
Returns:

python/datafusion/dataframe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Compression(Enum):
7373
LZ4_RAW = "lz4_raw"
7474

7575
@classmethod
76-
def from_str(cls, value: str) -> "Compression":
76+
def from_str(cls, value: str) -> Compression:
7777
"""Convert a string to a Compression enum value.
7878
7979
Args:
@@ -104,9 +104,9 @@ def get_default_level(self) -> Optional[int]:
104104
# https://github.com/apache/datafusion-python/pull/981#discussion_r1904789223
105105
if self == Compression.GZIP:
106106
return 6
107-
elif self == Compression.BROTLI:
107+
if self == Compression.BROTLI:
108108
return 1
109-
elif self == Compression.ZSTD:
109+
if self == Compression.ZSTD:
110110
return 4
111111
return None
112112

python/datafusion/expr.py

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -101,63 +101,63 @@
101101
WindowExpr = expr_internal.WindowExpr
102102

103103
__all__ = [
104-
"Expr",
105-
"Column",
106-
"Literal",
107-
"BinaryExpr",
108-
"Literal",
104+
"Aggregate",
109105
"AggregateFunction",
110-
"Not",
111-
"IsNotNull",
112-
"IsNull",
113-
"IsTrue",
114-
"IsFalse",
115-
"IsUnknown",
116-
"IsNotTrue",
117-
"IsNotFalse",
118-
"IsNotUnknown",
119-
"Negative",
120-
"Like",
121-
"ILike",
122-
"SimilarTo",
123-
"ScalarVariable",
124106
"Alias",
125-
"InList",
126-
"Exists",
127-
"Subquery",
128-
"InSubquery",
129-
"ScalarSubquery",
130-
"Placeholder",
131-
"GroupingSet",
107+
"Analyze",
108+
"Between",
109+
"BinaryExpr",
132110
"Case",
133111
"CaseBuilder",
134112
"Cast",
135-
"TryCast",
136-
"Between",
113+
"Column",
114+
"CreateMemoryTable",
115+
"CreateView",
116+
"Distinct",
117+
"DropTable",
118+
"EmptyRelation",
119+
"Exists",
137120
"Explain",
121+
"Expr",
122+
"Extension",
123+
"Filter",
124+
"GroupingSet",
125+
"ILike",
126+
"InList",
127+
"InSubquery",
128+
"IsFalse",
129+
"IsNotFalse",
130+
"IsNotNull",
131+
"IsNotTrue",
132+
"IsNotUnknown",
133+
"IsNull",
134+
"IsTrue",
135+
"IsUnknown",
136+
"Join",
137+
"JoinConstraint",
138+
"JoinType",
139+
"Like",
138140
"Limit",
139-
"Aggregate",
141+
"Literal",
142+
"Literal",
143+
"Negative",
144+
"Not",
145+
"Partitioning",
146+
"Placeholder",
147+
"Projection",
148+
"Repartition",
149+
"ScalarSubquery",
150+
"ScalarVariable",
151+
"SimilarTo",
140152
"Sort",
141153
"SortExpr",
142-
"Analyze",
143-
"EmptyRelation",
144-
"Join",
145-
"JoinType",
146-
"JoinConstraint",
154+
"Subquery",
155+
"SubqueryAlias",
156+
"TableScan",
157+
"TryCast",
147158
"Union",
148159
"Unnest",
149160
"UnnestExpr",
150-
"Extension",
151-
"Filter",
152-
"Projection",
153-
"TableScan",
154-
"CreateMemoryTable",
155-
"CreateView",
156-
"Distinct",
157-
"SubqueryAlias",
158-
"DropTable",
159-
"Partitioning",
160-
"Repartition",
161161
"Window",
162162
"WindowExpr",
163163
"WindowFrame",
@@ -311,7 +311,7 @@ def __getitem__(self, key: str | int) -> Expr:
311311
)
312312
return Expr(self.expr.__getitem__(key))
313313

314-
def __eq__(self, rhs: Any) -> Expr:
314+
def __eq__(self, rhs: object) -> Expr:
315315
"""Equal to.
316316
317317
Accepts either an expression or any valid PyArrow scalar literal value.
@@ -320,7 +320,7 @@ def __eq__(self, rhs: Any) -> Expr:
320320
rhs = Expr.literal(rhs)
321321
return Expr(self.expr.__eq__(rhs.expr))
322322

323-
def __ne__(self, rhs: Any) -> Expr:
323+
def __ne__(self, rhs: object) -> Expr:
324324
"""Not equal to.
325325
326326
Accepts either an expression or any valid PyArrow scalar literal value.

python/datafusion/input/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ class BaseInputSource(ABC):
4040
@abstractmethod
4141
def is_correct_input(self, input_item: Any, table_name: str, **kwargs) -> bool:
4242
"""Returns `True` if the input is valid."""
43-
pass
4443

4544
@abstractmethod
4645
def build_table(self, input_item: Any, table_name: str, **kwarg) -> SqlTable:
4746
"""Create a table from the input source."""
48-
pass

0 commit comments

Comments
 (0)