Thanks to visit codestin.com
Credit goes to github.com

Skip to content

use Ruff as formatter #1144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: checkout
uses: actions/checkout@v4

- uses: psf/black@stable
with:
options: "--check --verbose"
src: "."
- name: lint
uses: chartboost/ruff-action@v1

- uses: chartboost/ruff-action@v1
- name: check format
uses: chartboost/ruff-action@v1
with:
args: "format --diff"
4 changes: 2 additions & 2 deletions pymysql/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def advance(self, length):
new_position = self._position + length
if new_position < 0 or new_position > len(self._data):
raise Exception(
"Invalid advance amount (%s) for cursor. "
"Position=%s" % (length, new_position)
"Invalid advance amount (%s) for cursor. Position=%s"
% (length, new_position)
)
self._position = new_position

Expand Down
5 changes: 1 addition & 4 deletions pymysql/tests/test_SSCursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ def test_SSCursor(self):

# Create table
cursor.execute(
"CREATE TABLE tz_data ("
"region VARCHAR(64),"
"zone VARCHAR(64),"
"name VARCHAR(64))"
"CREATE TABLE tz_data (region VARCHAR(64), zone VARCHAR(64), name VARCHAR(64))"
)

conn.begin()
Expand Down
6 changes: 3 additions & 3 deletions pymysql/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def test_bulk_insert(self):

data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)]
cursor.executemany(
"insert into bulkinsert (id, name, age, height) " "values (%s,%s,%s,%s)",
"insert into bulkinsert (id, name, age, height) values (%s,%s,%s,%s)",
data,
)
self.assertEqual(
Expand Down Expand Up @@ -414,14 +414,14 @@ def test_bulk_insert_single_record(self):
cursor = conn.cursor()
data = [(0, "bob", 21, 123)]
cursor.executemany(
"insert into bulkinsert (id, name, age, height) " "values (%s,%s,%s,%s)",
"insert into bulkinsert (id, name, age, height) values (%s,%s,%s,%s)",
data,
)
cursor.execute("commit")
self._verify_records(data)

def test_issue_288(self):
"""executemany should work with "insert ... on update" """
"""executemany should work with "insert ... on update"""
conn = self.connect()
cursor = conn.cursor()
data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)]
Expand Down
3 changes: 1 addition & 2 deletions pymysql/tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def setUp(self):
)
cursor = conn.cursor()
cursor.execute(
"insert into test (data) values "
"('row1'), ('row2'), ('row3'), ('row4'), ('row5')"
"insert into test (data) values ('row1'), ('row2'), ('row3'), ('row4'), ('row5')"
)
conn.commit()
cursor.close()
Expand Down
5 changes: 2 additions & 3 deletions pymysql/tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,9 @@ def test_issue_321(self):

sql_insert = "insert into issue321 (value_1, value_2) values (%s, %s)"
sql_dict_insert = (
"insert into issue321 (value_1, value_2) "
"values (%(value_1)s, %(value_2)s)"
"insert into issue321 (value_1, value_2) values (%(value_1)s, %(value_2)s)"
)
sql_select = "select * from issue321 where " "value_1 in %s and value_2=%s"
sql_select = "select * from issue321 where value_1 in %s and value_2=%s"
data = [
[("a",), "\u0430"],
[["b"], "\u0430"],
Expand Down
2 changes: 1 addition & 1 deletion pymysql/tests/test_nextset.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_multi_statement_warnings(self):
cursor = con.cursor()

try:
cursor.execute("DROP TABLE IF EXISTS a; " "DROP TABLE IF EXISTS b;")
cursor.execute("DROP TABLE IF EXISTS a; DROP TABLE IF EXISTS b;")
except TypeError:
self.fail()

Expand Down
8 changes: 4 additions & 4 deletions pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_rowcount(self):
self.assertEqual(
cur.rowcount,
-1,
"cursor.rowcount should be -1 after executing no-result " "statements",
"cursor.rowcount should be -1 after executing no-result statements",
)
cur.execute(
"insert into %sbooze values ('Victoria Bitter')" % (self.table_prefix)
Expand Down Expand Up @@ -409,12 +409,12 @@ def _paraminsert(self, cur):
self.assertEqual(
beers[0],
"Cooper's",
"cursor.fetchall retrieved incorrect data, or data inserted " "incorrectly",
"cursor.fetchall retrieved incorrect data, or data inserted incorrectly",
)
self.assertEqual(
beers[1],
"Victoria Bitter",
"cursor.fetchall retrieved incorrect data, or data inserted " "incorrectly",
"cursor.fetchall retrieved incorrect data, or data inserted incorrectly",
)

def test_executemany(self):
Expand Down Expand Up @@ -482,7 +482,7 @@ def test_fetchone(self):
self.assertEqual(
cur.fetchone(),
None,
"cursor.fetchone should return None if a query retrieves " "no rows",
"cursor.fetchone should return None if a query retrieves no rows",
)
self.assertTrue(cur.rowcount in (-1, 0))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_fetchone(self):
self.assertEqual(
cur.fetchone(),
None,
"cursor.fetchone should return None if a query retrieves " "no rows",
"cursor.fetchone should return None if a query retrieves no rows",
)
self.assertTrue(cur.rowcount in (-1, 0))

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ exclude = ["tests*", "pymysql.tests*"]
version = {attr = "pymysql.VERSION_STRING"}

[tool.ruff]
line-length = 99
exclude = [
"pymysql/tests/thirdparty",
]
Expand Down