Skip to content

Commit a515c66

Browse files
authored
chore: replace black, flake8, and isort with ruff (#4054)
Closes #4053 --------- Co-authored-by: Emil Sadek <esadek@users.noreply.github.com>
1 parent e3b6942 commit a515c66

15 files changed

Lines changed: 48 additions & 62 deletions

File tree

.isort.cfg

Lines changed: 0 additions & 20 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,14 @@ repos:
7575
- id: pretty-format-java
7676
args: [--autofix]
7777
types_or: [java]
78-
- repo: https://github.com/psf/black
79-
rev: 8a737e727ac5ab2f1d4cf5876720ed276dc8dc4b # 25.1.0
78+
- repo: https://github.com/astral-sh/ruff-pre-commit
79+
rev: b969e2851312ca2b24bbec879ba4954341d1bd12 # v0.15.5
8080
hooks:
81-
- id: black
82-
types_or: [pyi, python]
83-
- repo: https://github.com/PyCQA/flake8
84-
rev: bddd87797f8dfc07d2a10c894776018d9bec590b # 7.1.2
85-
hooks:
86-
- id: flake8
87-
types_or: [python]
88-
- repo: https://github.com/PyCQA/isort
89-
rev: 0a0b7a830386ba6a31c2ec8316849ae4d1b8240d # 6.0.0
90-
hooks:
91-
- id: isort
92-
types_or: [python]
81+
- id: ruff-check
82+
types_or: [python, pyi]
83+
args: [--fix]
84+
- id: ruff-format
85+
types_or: [python, pyi]
9386
- repo: https://github.com/MarcoGorelli/cython-lint
9487
rev: 9247866fce7128f2c0eaf4a09f437880397d4689 # v0.16.2
9588
hooks:

c/driver/postgresql/validation/tests/test_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from adbc_drivers_validation.tests.connection import TestConnection # noqa: F401
1918
from adbc_drivers_validation.tests.connection import (
19+
TestConnection, # noqa: F401
2020
generate_tests,
2121
)
2222

c/driver/postgresql/validation/tests/test_ingest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from adbc_drivers_validation.tests.ingest import TestIngest # noqa: F401
1918
from adbc_drivers_validation.tests.ingest import (
19+
TestIngest, # noqa: F401
2020
generate_tests,
2121
)
2222

c/driver/postgresql/validation/tests/test_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from adbc_drivers_validation.tests.query import TestQuery # noqa: F401
1918
from adbc_drivers_validation.tests.query import (
19+
TestQuery, # noqa: F401
2020
generate_tests,
2121
)
2222

c/driver/postgresql/validation/tests/test_statement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
from adbc_drivers_validation.tests.statement import TestStatement # noqa: F401
1918
from adbc_drivers_validation.tests.statement import (
19+
TestStatement, # noqa: F401
2020
generate_tests,
2121
)
2222

dev/bench/run_bench.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,21 @@ def execute_task(task, cursor, table_name, iteration_cnt, row_count_limit=50000)
133133
# with snowflake.connector.connect(
134134
# **CONNECTION_PARAMETERS
135135
# ) as conn, conn.cursor() as cursor:
136-
with adbc_driver_snowflake.dbapi.connect(
137-
**ADBC_CONNECTION_PARAMETERS
138-
) as conn, conn.cursor() as cursor:
136+
with (
137+
adbc_driver_snowflake.dbapi.connect(**ADBC_CONNECTION_PARAMETERS) as conn,
138+
conn.cursor() as cursor,
139+
):
139140
cursor.adbc.statement.set_options(
140141
**{
141142
"adbc.snowflake.rpc.prefetch_concurrency": 4,
142143
"adbc.rpc.result_queue_size": 100,
143144
}
144145
)
145146

146-
with open(perf_record_file, "w") as perf_file, open(
147-
memory_record_file, "w"
148-
) as memory_file:
147+
with (
148+
open(perf_record_file, "w") as perf_file,
149+
open(memory_record_file, "w") as memory_file,
150+
):
149151
# task = task_execution_decorator( # snowflake python connector
150152
# task_fetch_arrow_batches, perf_file, memory_file)
151153
# task = task_execution_decorator( # pyodbc
@@ -158,9 +160,10 @@ def execute_task(task, cursor, table_name, iteration_cnt, row_count_limit=50000)
158160
)
159161

160162
if can_draw:
161-
with open(perf_record_file) as perf_file, open(
162-
memory_record_file
163-
) as memory_file:
163+
with (
164+
open(perf_record_file) as perf_file,
165+
open(memory_record_file) as memory_file,
166+
):
164167
# sample rate
165168
perf_lines = perf_file.readlines()
166169
perf_records = [float(line) for line in perf_lines]

docs/source/ext/doxygen_inventory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def scrape_links(item_id_to_url, root):
9999
continue
100100
else:
101101
raise NotImplementedError(
102-
f"<memberdef kind=\"{memberdef.attrib['kind']}\"> not supported"
102+
f'<memberdef kind="{memberdef.attrib["kind"]}"> not supported'
103103
)
104104

105105
anchor = parse_member_id(memberdef.attrib["id"])

glib/tool/generate-version-header.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20+
# ruff: noqa: E501
2021

2122
import argparse
2223
import re
@@ -41,9 +42,10 @@ def main():
4142

4243
args = parser.parse_args()
4344

44-
with open(args.input, "r", encoding="utf-8") as input_file, open(
45-
args.output, "w", encoding="utf-8"
46-
) as output_file:
45+
with (
46+
open(args.input, "r", encoding="utf-8") as input_file,
47+
open(args.output, "w", encoding="utf-8") as output_file,
48+
):
4749
write_header(input_file, output_file, args.library, args.version)
4850

4951

@@ -106,7 +108,7 @@ def generate_encoded_versions(library: str) -> str:
106108
*
107109
* Since: {major_version}.{minor_version}.0
108110
*/
109-
#define {library}_VERSION_{major_version}_{minor_version} G_ENCODE_VERSION({major_version}, {minor_version})""" # noqa: #501
111+
#define {library}_VERSION_{major_version}_{minor_version} G_ENCODE_VERSION({major_version}, {minor_version})"""
110112
)
111113

112114
return "\n\n".join(macros)
@@ -129,7 +131,7 @@ def generate_availability_macros(library: str) -> str:
129131
# define {library}_AVAILABLE_IN_{major_version}_{minor_version} {library}_EXTERN {library}_UNAVAILABLE({major_version}, {minor_version})
130132
#else
131133
# define {library}_AVAILABLE_IN_{major_version}_{minor_version} {library}_EXTERN
132-
#endif""" # noqa: #501
134+
#endif"""
133135
)
134136

135137
return "\n\n".join(macros)

python/adbc_driver_bigquery/adbc_driver_bigquery/dbapi.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import typing
2323

2424
import adbc_driver_bigquery
25-
2625
import adbc_driver_manager
2726
import adbc_driver_manager.dbapi
2827

0 commit comments

Comments
 (0)