This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new a515c6678 chore: replace black, flake8, and isort with ruff (#4054)
a515c6678 is described below
commit a515c6678561b1b3320472948f239c482f6225b7
Author: Emil Sadek <[email protected]>
AuthorDate: Sun Mar 8 04:03:27 2026 -0700
chore: replace black, flake8, and isort with ruff (#4054)
Closes #4053
---------
Co-authored-by: Emil Sadek <[email protected]>
---
.isort.cfg | 20 --------------------
.pre-commit-config.yaml | 21 +++++++--------------
.../postgresql/validation/tests/test_connection.py | 2 +-
c/driver/postgresql/validation/tests/test_ingest.py | 2 +-
c/driver/postgresql/validation/tests/test_query.py | 2 +-
.../postgresql/validation/tests/test_statement.py | 2 +-
dev/bench/run_bench.py | 21 ++++++++++++---------
docs/source/ext/doxygen_inventory.py | 2 +-
glib/tool/generate-version-header.py | 12 +++++++-----
.../adbc_driver_bigquery/dbapi.py | 1 -
python/adbc_driver_bigquery/tests/test_dbapi.py | 1 +
python/adbc_driver_bigquery/tests/test_lowlevel.py | 4 ++--
python/adbc_driver_flightsql/tests/test_errors.py | 2 +-
.../adbc_driver_manager/dbapi.py | 3 +--
.flake8 => ruff.toml | 15 ++++++++++++---
15 files changed, 48 insertions(+), 62 deletions(-)
diff --git a/.isort.cfg b/.isort.cfg
deleted file mode 100644
index 1d6b38010..000000000
--- a/.isort.cfg
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-[settings]
-known_first_party = adbc_driver_flightsql, adbc_driver_manager,
adbc_driver_postgresql, adbc_driver_sqlite, adbc_driver_snowflake
-profile = black
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index cd7f0097e..51e925991 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -75,21 +75,14 @@ repos:
- id: pretty-format-java
args: [--autofix]
types_or: [java]
- - repo: https://github.com/psf/black
- rev: 8a737e727ac5ab2f1d4cf5876720ed276dc8dc4b # 25.1.0
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: b969e2851312ca2b24bbec879ba4954341d1bd12 # v0.15.5
hooks:
- - id: black
- types_or: [pyi, python]
- - repo: https://github.com/PyCQA/flake8
- rev: bddd87797f8dfc07d2a10c894776018d9bec590b # 7.1.2
- hooks:
- - id: flake8
- types_or: [python]
- - repo: https://github.com/PyCQA/isort
- rev: 0a0b7a830386ba6a31c2ec8316849ae4d1b8240d # 6.0.0
- hooks:
- - id: isort
- types_or: [python]
+ - id: ruff-check
+ types_or: [python, pyi]
+ args: [--fix]
+ - id: ruff-format
+ types_or: [python, pyi]
- repo: https://github.com/MarcoGorelli/cython-lint
rev: 9247866fce7128f2c0eaf4a09f437880397d4689 # v0.16.2
hooks:
diff --git a/c/driver/postgresql/validation/tests/test_connection.py
b/c/driver/postgresql/validation/tests/test_connection.py
index 7c719bbf5..89b1c15f6 100644
--- a/c/driver/postgresql/validation/tests/test_connection.py
+++ b/c/driver/postgresql/validation/tests/test_connection.py
@@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from adbc_drivers_validation.tests.connection import TestConnection # noqa:
F401
from adbc_drivers_validation.tests.connection import (
+ TestConnection, # noqa: F401
generate_tests,
)
diff --git a/c/driver/postgresql/validation/tests/test_ingest.py
b/c/driver/postgresql/validation/tests/test_ingest.py
index e764e577d..9fded6f37 100644
--- a/c/driver/postgresql/validation/tests/test_ingest.py
+++ b/c/driver/postgresql/validation/tests/test_ingest.py
@@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from adbc_drivers_validation.tests.ingest import TestIngest # noqa: F401
from adbc_drivers_validation.tests.ingest import (
+ TestIngest, # noqa: F401
generate_tests,
)
diff --git a/c/driver/postgresql/validation/tests/test_query.py
b/c/driver/postgresql/validation/tests/test_query.py
index 3750be471..a2f396497 100644
--- a/c/driver/postgresql/validation/tests/test_query.py
+++ b/c/driver/postgresql/validation/tests/test_query.py
@@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from adbc_drivers_validation.tests.query import TestQuery # noqa: F401
from adbc_drivers_validation.tests.query import (
+ TestQuery, # noqa: F401
generate_tests,
)
diff --git a/c/driver/postgresql/validation/tests/test_statement.py
b/c/driver/postgresql/validation/tests/test_statement.py
index 5420e62f9..ee33cd087 100644
--- a/c/driver/postgresql/validation/tests/test_statement.py
+++ b/c/driver/postgresql/validation/tests/test_statement.py
@@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-from adbc_drivers_validation.tests.statement import TestStatement # noqa: F401
from adbc_drivers_validation.tests.statement import (
+ TestStatement, # noqa: F401
generate_tests,
)
diff --git a/dev/bench/run_bench.py b/dev/bench/run_bench.py
index 0ce2fbcf3..cef351a72 100644
--- a/dev/bench/run_bench.py
+++ b/dev/bench/run_bench.py
@@ -133,9 +133,10 @@ if __name__ == "__main__":
# with snowflake.connector.connect(
# **CONNECTION_PARAMETERS
# ) as conn, conn.cursor() as cursor:
- with adbc_driver_snowflake.dbapi.connect(
- **ADBC_CONNECTION_PARAMETERS
- ) as conn, conn.cursor() as cursor:
+ with (
+ adbc_driver_snowflake.dbapi.connect(**ADBC_CONNECTION_PARAMETERS) as
conn,
+ conn.cursor() as cursor,
+ ):
cursor.adbc.statement.set_options(
**{
"adbc.snowflake.rpc.prefetch_concurrency": 4,
@@ -143,9 +144,10 @@ if __name__ == "__main__":
}
)
- with open(perf_record_file, "w") as perf_file, open(
- memory_record_file, "w"
- ) as memory_file:
+ with (
+ open(perf_record_file, "w") as perf_file,
+ open(memory_record_file, "w") as memory_file,
+ ):
# task = task_execution_decorator( # snowflake python connector
# task_fetch_arrow_batches, perf_file, memory_file)
# task = task_execution_decorator( # pyodbc
@@ -158,9 +160,10 @@ if __name__ == "__main__":
)
if can_draw:
- with open(perf_record_file) as perf_file, open(
- memory_record_file
- ) as memory_file:
+ with (
+ open(perf_record_file) as perf_file,
+ open(memory_record_file) as memory_file,
+ ):
# sample rate
perf_lines = perf_file.readlines()
perf_records = [float(line) for line in perf_lines]
diff --git a/docs/source/ext/doxygen_inventory.py
b/docs/source/ext/doxygen_inventory.py
index 3e969cadb..d1e882d44 100644
--- a/docs/source/ext/doxygen_inventory.py
+++ b/docs/source/ext/doxygen_inventory.py
@@ -99,7 +99,7 @@ def scrape_links(item_id_to_url, root):
continue
else:
raise NotImplementedError(
- f"<memberdef kind=\"{memberdef.attrib['kind']}\"> not
supported"
+ f'<memberdef kind="{memberdef.attrib["kind"]}"> not
supported'
)
anchor = parse_member_id(memberdef.attrib["id"])
diff --git a/glib/tool/generate-version-header.py
b/glib/tool/generate-version-header.py
index bc8cc33ca..d4f8036c6 100755
--- a/glib/tool/generate-version-header.py
+++ b/glib/tool/generate-version-header.py
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+# ruff: noqa: E501
import argparse
import re
@@ -41,9 +42,10 @@ def main():
args = parser.parse_args()
- with open(args.input, "r", encoding="utf-8") as input_file, open(
- args.output, "w", encoding="utf-8"
- ) as output_file:
+ with (
+ open(args.input, "r", encoding="utf-8") as input_file,
+ open(args.output, "w", encoding="utf-8") as output_file,
+ ):
write_header(input_file, output_file, args.library, args.version)
@@ -106,7 +108,7 @@ def generate_encoded_versions(library: str) -> str:
*
* Since: {major_version}.{minor_version}.0
*/
-#define {library}_VERSION_{major_version}_{minor_version}
G_ENCODE_VERSION({major_version}, {minor_version})""" # noqa: #501
+#define {library}_VERSION_{major_version}_{minor_version}
G_ENCODE_VERSION({major_version}, {minor_version})"""
)
return "\n\n".join(macros)
@@ -129,7 +131,7 @@ def generate_availability_macros(library: str) -> str:
# define {library}_AVAILABLE_IN_{major_version}_{minor_version}
{library}_EXTERN {library}_UNAVAILABLE({major_version}, {minor_version})
#else
# define {library}_AVAILABLE_IN_{major_version}_{minor_version}
{library}_EXTERN
-#endif""" # noqa: #501
+#endif"""
)
return "\n\n".join(macros)
diff --git a/python/adbc_driver_bigquery/adbc_driver_bigquery/dbapi.py
b/python/adbc_driver_bigquery/adbc_driver_bigquery/dbapi.py
index efdeaebc3..686e0b92b 100644
--- a/python/adbc_driver_bigquery/adbc_driver_bigquery/dbapi.py
+++ b/python/adbc_driver_bigquery/adbc_driver_bigquery/dbapi.py
@@ -22,7 +22,6 @@ DBAPI 2.0-compatible facade for the ADBC BigQuery driver.
import typing
import adbc_driver_bigquery
-
import adbc_driver_manager
import adbc_driver_manager.dbapi
diff --git a/python/adbc_driver_bigquery/tests/test_dbapi.py
b/python/adbc_driver_bigquery/tests/test_dbapi.py
index ad7d57607..c153fe7cb 100644
--- a/python/adbc_driver_bigquery/tests/test_dbapi.py
+++ b/python/adbc_driver_bigquery/tests/test_dbapi.py
@@ -16,6 +16,7 @@
# under the License.
import pytest
+
from adbc_driver_bigquery import DatabaseOptions, dbapi
diff --git a/python/adbc_driver_bigquery/tests/test_lowlevel.py
b/python/adbc_driver_bigquery/tests/test_lowlevel.py
index f0340b2f3..827bb62d8 100644
--- a/python/adbc_driver_bigquery/tests/test_lowlevel.py
+++ b/python/adbc_driver_bigquery/tests/test_lowlevel.py
@@ -16,12 +16,12 @@
# under the License.
-import adbc_driver_bigquery
import pyarrow
import pytest
-from adbc_driver_bigquery import DatabaseOptions
+import adbc_driver_bigquery
import adbc_driver_manager
+from adbc_driver_bigquery import DatabaseOptions
@pytest.fixture
diff --git a/python/adbc_driver_flightsql/tests/test_errors.py
b/python/adbc_driver_flightsql/tests/test_errors.py
index fe85e4f22..00110c472 100644
--- a/python/adbc_driver_flightsql/tests/test_errors.py
+++ b/python/adbc_driver_flightsql/tests/test_errors.py
@@ -154,7 +154,7 @@ def test_query_error_bind(test_dbapi):
with pytest.raises(
test_dbapi.OperationalError,
match=re.escape(
- "UNKNOWN: [FlightSQL] expected error (DoPut)" " (Unknown;
ExecuteQuery)"
+ "UNKNOWN: [FlightSQL] expected error (DoPut) (Unknown;
ExecuteQuery)"
),
) as excval:
cur.execute("error_do_put_detail", parameters=(1, "a"))
diff --git a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
index fb83b04f3..525596c18 100644
--- a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
+++ b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
@@ -353,8 +353,7 @@ class Connection(_Closeable):
except _lib.NotSupportedError:
self._commit_supported = False
warnings.warn(
- "Cannot disable autocommit; "
- "conn will not be DB-API 2.0 compliant",
+ "Cannot disable autocommit; conn will not be DB-API 2.0
compliant",
category=Warning,
)
self._autocommit = True
diff --git a/.flake8 b/ruff.toml
similarity index 76%
rename from .flake8
rename to ruff.toml
index cda8c86b1..26028197f 100644
--- a/.flake8
+++ b/ruff.toml
@@ -15,6 +15,15 @@
# specific language governing permissions and limitations
# under the License.
-[flake8]
-max-line-length = 88
-extend-ignore = E203
+[lint]
+select = ["E", "F", "I", "W"]
+
+[lint.isort]
+known-first-party = [
+ "adbc_driver_bigquery",
+ "adbc_driver_flightsql",
+ "adbc_driver_manager",
+ "adbc_driver_postgresql",
+ "adbc_driver_snowflake",
+ "adbc_driver_sqlite",
+]