8000 use Ruff as formatter (#1144) · PyMySQL/PyMySQL@84d3f93 · GitHub
[go: up one dir, main page]

Skip to content

Commit 84d3f93

Browse files
authored
use Ruff as formatter (#1144)
1 parent 1ed7cff commit 84d3f93

File tree

10 files changed

+23
-27
lines changed

10 files changed

+23
-27
lines changed

.github/workflows/lint.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ jobs:
1313
lint:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
16+
- name: checkout
17+
uses: actions/checkout@v4
1718

18-
- uses: psf/black@stable
19-
with:
20-
options: "--check --verbose"
21-
src: "."
19+
- name: lint
20+
uses: chartboost/ruff-action@v1
2221

23-
- uses: chartboost/ruff-action@v1
22+
- name: check format
23+
uses: chartboost/ruff-action@v1
24+
with:
25+
args: "format --diff"

pymysql/protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def advance(self, length):
8989
new_position = self._position + length
9090
if new_position < 0 or new_position > len(self._data):
9191
raise Exception(
92-
"Invalid advance amount (%s) for cursor. "
93-
"Position=%s" % (length, new_position)
92+
"Invalid advance amount (%s) for cursor. Position=%s"
93+
% (length, new_position)
9494
)
9595
self._position = new_position
9696

pymysql/tests/test_SSCursor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ def test_SSCursor(self):
2727

2828
# Create table
2929
cursor.execute(
30-
"CREATE TABLE tz_data ("
31-
"region VARCHAR(64),"
32-
"zone VARCHAR(64),"
33-
"name VARCHAR(64))"
30+
"CREATE TABLE tz_data (region VARCHAR(64), zone VARCHAR(64), name VARCHAR(64))"
3431
)
3532

3633
conn.begin()

pymysql/tests/test_basic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def test_bulk_insert(self):
364364

365365
data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)]
366366
cursor.executemany(
367-
"insert into bulkinsert (id, name, age, height) " "values (%s,%s,%s,%s)",
367+
"insert into bulkinsert (id, name, age, height) values (%s,%s,%s,%s)",
368368
data,
369369
)
370370
self.assertEqual(
@@ -414,14 +414,14 @@ def test_bulk_insert_single_record(self):
414414
cursor = conn.cursor()
415415
data = [(0, "bob", 21, 123)]
416416
cursor.executemany(
417-
"insert into bulkinsert (id, name, age, height) " "values (%s,%s,%s,%s)",
417+
"insert into bulkinsert (id, name, age, height) values (%s,%s,%s,%s)",
418418
data,
419419
)
420420
cursor.execute("commit")
421421
self._verify_records(data)
422422

423423
def test_issue_288(self):
424-
"""executemany should work with "insert ... on update" """
424+
"""executemany should work with "insert ... on update"""
425425
conn = self.connect()
426426
cursor = conn.cursor()
427427
data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)]

pymysql/tests/test_cursor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def setUp(self):
1717
)
1818
cursor = conn.cursor()
1919
cursor.execute(
20-
"insert into test (data) values "
21-
"('row1'), ('row2'), ('row3'), ('row4'), ('row5')"
20+
"insert into test (data) values ('row1'), ('row2'), ('row3'), ('row4'), ('row5')"
2221
)
2322
conn.commit()
2423
cursor.close()

pymysql/tests/test_issues.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,9 @@ def test_issue_321(self):
401401

402402
sql_insert = "insert into issue321 (value_1, value_2) values (%s, %s)"
403403
sql_dict_insert = (
404-
"insert into issue321 (value_1, value_2) "
405-
"values (%(value_1)s, %(value_2)s)"
404+
"insert into issue321 (value_1, value_2) values (%(value_1)s, %(value_2)s)"
406405
)
407-
sql_select = "select * from issue321 where " "value_1 in %s and value_2=%s"
406+
sql_select = "select * from issue321 where value_1 in %s and value_2=%s"
408407
data = [
409408
[("a",), "\u0430"],
410409
[["b"], "\u0430"],

pymysql/tests/test_nextset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_multi_statement_warnings(self):
7575
cursor = con.cursor()
7676

7777
try:
78-
cursor.execute("DROP TABLE IF EXISTS a; " "DROP TABLE IF EXISTS b;")
78+
cursor.execute("DROP TABLE IF EXISTS a; DROP TABLE IF EXISTS b;")
7979
except TypeError:
8080
self.fail()
8181

pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def test_rowcount(self):
299299
self.assertEqual(
300300
cur.rowcount,
301301
-1,
302-
"cursor.rowcount should be -1 after executing no-result " "statements",
302+
"cursor.rowcount should be -1 after executing no-result statements",
303303
)
304304
cur.execute(
305305
"insert into %sbooze values ('Victoria Bitter')" % (self.table_prefix)
@@ -409,12 +409,12 @@ def _paraminsert(self, cur):
409409
self.assertEqual(
410410
beers[0],
411411
"Cooper's",
412-
"cursor.fetchall retrieved incorrect data, or data inserted " "incorrectly",
412+
"cursor.fetchall retrieved incorrect data, or data inserted incorrectly",
413413
)
414414
self.assertEqual(
415415
beers[1],
416416
"Victoria Bitter",
417-
"cursor.fetchall retrieved incorrect data, or data inserted " "incorrectly",
417+
"cursor.fetchall retrieved incorrect data, or data inserted incorrectly",
418418
)
419419

420420
def test_executemany(self):
@@ -482,7 +482,7 @@ def test_fetchone(self):
482482
self.assertEqual(
483483
cur.fetchone(),
484484
None,
485-
"cursor.fetchone should return None if a query retrieves " "no rows",
485+
"cursor.fetchone should return None if a query retrieves no rows",
486486
)
487487
self.assertTrue(cur.rowcount in (-1, 0))
488488

pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_fetchone(self):
9898
self.assertEqual(
9999
cur.fetchone(),
100100
None,
101-
"cursor.fetchone should return None if a query retrieves " "no rows",
101+
"cursor.fetchone should return None if a query retrieves no rows",
102102
)
103103
self.assertTrue(cur.rowcount in (-1, 0))
104104

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ exclude = ["tests*", "pymysql.tests*"]
5353
version = {attr = "pymysql.VERSION_STRING"}
5454

5555
[tool.ruff]
56-
line-length = 99
5756
exclude = [
5857
"pymysql/tests/thirdparty",
5958
]

0 commit comments

Comments
 (0)
0