Skip to content

Commit 0eed7e2

Browse files
committed
Update Black to the latest version 23.1.0
This patch also applies the suggested changes. Change-Id: I6bbf4b26f3c2953cd728ec004b552356d6788b23
1 parent 1eb8798 commit 0eed7e2

24 files changed

+26
-64
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2022, 2023, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -28,7 +28,7 @@
2828

2929
repos:
3030
- repo: https://github.com/psf/black
31-
rev: 22.6.0
31+
rev: 23.1.0
3232
hooks:
3333
- id: black
3434
- repo: https://github.com/pycqa/isort

cpydist/data/deb/connector_python_pack_deb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright (c) 2020, 2022, Oracle and/or its affiliates.
3+
# Copyright (c) 2020, 2023, Oracle and/or its affiliates.
44
#
55
# This program is free software; you can redistribute it and/or modify
66
# it under the terms of the GNU General Public License, version 2.0, as
@@ -270,7 +270,6 @@ def get_changes():
270270

271271

272272
def rename_tar():
273-
274273
# Here "orig" is not "original", but the TAR naming the Deb build needs
275274
# The TAR is assumed to be one level up, i.e. in PB2WORKDIR
276275
tarball = os.path.join(os.path.dirname(cwd), basename_tar + ".tar.gz")

examples/engines.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -60,7 +60,6 @@ def main(config):
6060

6161

6262
if __name__ == "__main__":
63-
6463
config = {
6564
"host": "localhost",
6665
"port": 3306,

examples/inserts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -85,7 +85,6 @@ def main(config):
8585

8686

8787
if __name__ == "__main__":
88-
8988
config = {
9089
"host": "localhost",
9190
"port": 3306,

examples/microseconds.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -125,7 +125,6 @@ def main(config):
125125

126126

127127
if __name__ == "__main__":
128-
129128
config = {
130129
"host": "localhost",
131130
"port": 3306,

examples/multi_resultsets.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -91,7 +91,6 @@ def main(config):
9191

9292

9393
if __name__ == "__main__":
94-
9594
config = {
9695
"host": "localhost",
9796
"port": 3306,

examples/mysql_warnings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -66,7 +66,6 @@ def main(config):
6666

6767

6868
if __name__ == "__main__":
69-
7069
config = {
7170
"host": "localhost",
7271
"port": 3306,

examples/prepared_statements.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -88,7 +88,6 @@ def main(config):
8888

8989

9090
if __name__ == "__main__":
91-
9291
config = {
9392
"host": "localhost",
9493
"port": 3306,

examples/transaction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -128,7 +128,6 @@ def main(config):
128128

129129

130130
if __name__ == "__main__":
131-
132131
config = {
133132
"host": "localhost",
134133
"port": 3306,

examples/unicode.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0, as
@@ -88,7 +88,6 @@ def main(config):
8888

8989

9090
if __name__ == "__main__":
91-
9291
config = {
9392
"host": "localhost",
9493
"port": 3306,

lib/mysql/connector/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def get_exception(packet: bytes) -> ErrorTypes:
287287
errmsg = packet.decode("utf8")
288288
except (IndexError, UnicodeError) as err:
289289
return InterfaceError(f"Failed getting Error information ({err})")
290-
return get_mysql_exception(errno, errmsg, sqlstate)
290+
return get_mysql_exception(errno, errmsg, sqlstate) # type: ignore[arg-type]
291291

292292

293293
_SQLSTATE_CLASS_EXCEPTION: Dict[str, ErrorClassTypes] = {

lib/mysqlx/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def get_exception(packet: bytes) -> ErrorTypes:
209209
errmsg = packet.decode("utf8")
210210
except (IndexError, ValueError) as err:
211211
return InterfaceError(f"Failed getting Error information ({err})")
212-
return get_mysql_exception(errno, errmsg, sqlstate)
212+
return get_mysql_exception(errno, errmsg, sqlstate) # type: ignore[arg-type]
213213

214214

215215
_SQLSTATE_CLASS_EXCEPTION: Dict[str, ErrorClassTypes] = {

support/django/run_django_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
44
#
55
# This program is free software; you can redistribute it and/or modify
66
# it under the terms of the GNU General Public License, version 2.0, as
@@ -332,7 +332,6 @@ def django_tests(
332332

333333

334334
def get_django_version(path):
335-
336335
VERSION = [999, 0, 0, "a", 0] # Set correct after version.py is loaded
337336
py_module = os.path.join(path, "django", "__init__.py")
338337
with open(py_module, "rb") as fp:

tests/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2013, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2013, 2023, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -651,7 +651,6 @@ def get_clean_mysql_config(self):
651651

652652
class TestsCursor(MySQLConnectorTests):
653653
def _test_execute_setup(self, cnx, tbl="myconnpy_cursor", engine="InnoDB"):
654-
655654
self._test_execute_cleanup(cnx, tbl)
656655
stmt_create = (
657656
"CREATE TABLE {table} "
@@ -667,7 +666,6 @@ def _test_execute_setup(self, cnx, tbl="myconnpy_cursor", engine="InnoDB"):
667666
cur.close()
668667

669668
def _test_execute_cleanup(self, cnx, tbl="myconnpy_cursor"):
670-
671669
stmt_drop = "DROP TABLE IF EXISTS {table}".format(table=tbl)
672670

673671
try:
@@ -712,7 +710,6 @@ def connc_connect_args(self, recache=False):
712710

713711

714712
class CMySQLCursorTests(CMySQLConnectorTests):
715-
716713
_cleanup_tables = []
717714

718715
def setUp(self):
@@ -727,7 +724,6 @@ def tearDown(self):
727724
self.cnx.close()
728725

729726
def setup_table(self, cnx, tbl="myconnpy_cursor", engine="InnoDB"):
730-
731727
self.cleanup_table(cnx, tbl)
732728
stmt_create = (
733729
"CREATE TABLE {table} "
@@ -749,7 +745,6 @@ def setup_table(self, cnx, tbl="myconnpy_cursor", engine="InnoDB"):
749745
self._cleanup_tables.append(tbl)
750746

751747
def cleanup_table(self, cnx, tbl="myconnpy_cursor"):
752-
753748
stmt_drop = "DROP TABLE IF EXISTS {table}".format(table=tbl)
754749

755750
# Explicit rollback: uncommited changes could otherwise block

tests/cext/test_cext_cursor.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ def test_executemany(self):
277277
cur.close()
278278

279279
def _test_callproc_setup(self, cnx):
280-
281280
self._test_callproc_cleanup(cnx)
282281
stmt_create1 = (
283282
"CREATE PROCEDURE myconnpy_sp_1 "
@@ -327,7 +326,6 @@ def _test_callproc_setup(self, cnx):
327326
cur.close()
328327

329328
def _test_callproc_cleanup(self, cnx):
330-
331329
sp_names = (
332330
"myconnpy_sp_1",
333331
"myconnpy_sp_2",
@@ -799,7 +797,6 @@ def test_fetchone(self):
799797

800798

801799
class CMySQLCursorPreparedTests(tests.CMySQLCursorTests):
802-
803800
tbl = "prep_stmt"
804801

805802
create_table_stmt = (
@@ -1040,7 +1037,6 @@ def test_executemany(self):
10401037

10411038

10421039
class CMySQLCursorPreparedDictTests(CMySQLCursorPreparedTests):
1043-
10441040
tbl = "prep_dict_stmt"
10451041

10461042
column_names = (
@@ -1154,7 +1150,6 @@ def test_executemany(self):
11541150

11551151

11561152
class CMySQLCursorPreparedNamedTupleTests(CMySQLCursorPreparedTests):
1157-
11581153
tbl = "prep_named_tuple_stmt"
11591154

11601155
column_names = (
@@ -1261,7 +1256,6 @@ def test_executemany(self):
12611256

12621257

12631258
class CMySQLCursorPreparedRawTests(CMySQLCursorPreparedTests):
1264-
12651259
tbl = "prep_raw_stmt"
12661260

12671261
column_names = (

tests/test_authentication.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2014, 2022, Oracle and/or its affiliates.
3+
# Copyright (c) 2014, 2023, Oracle and/or its affiliates.
44
#
55
# This program is free software; you can redistribute it and/or modify
66
# it under the terms of the GNU General Public License, version 2.0, as
@@ -147,7 +147,6 @@ def test_class(self):
147147
self.assertEqual(False, self.plugin_class.requires_ssl)
148148

149149
def test_prepare_password(self):
150-
151150
auth_plugin = self.plugin_class(None, password="spam")
152151
self.assertRaises(mysql.connector.InterfaceError, auth_plugin.prepare_password)
153152

tests/test_bugs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,6 @@ class BugOra16217765(tests.MySQLConnectorTests):
24892489
}
24902490

24912491
def _create_user(self, cnx, user, password, host, database, plugin):
2492-
24932492
self._drop_user(cnx, user, host)
24942493
create_user = "CREATE USER '{user}'@'{host}' IDENTIFIED WITH {plugin}"
24952494
cnx.cmd_query(create_user.format(user=user, host=host, plugin=plugin))

tests/test_connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates.
1+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -264,7 +264,7 @@ def test__handle_server_status(self):
264264
False,
265265
),
266266
]
267-
for (flag, attr, when_set, when_unset) in cases:
267+
for flag, attr, when_set, when_unset in cases:
268268
setattr(self.cnx, attr, when_unset)
269269
self.cnx._handle_server_status(flag)
270270
self.assertEqual(when_set, getattr(self.cnx, attr))
@@ -2357,7 +2357,7 @@ def verify_load_fails(cur, data_file, err_msgs, exception=errors.DatabaseError):
23572357
cnx.close()
23582358
try:
23592359
os.remove(link)
2360-
except (FileNotFoundError):
2360+
except FileNotFoundError:
23612361
pass
23622362

23632363
if os.name != "nt" and connector_class != CMySQLConnection:
@@ -2375,7 +2375,7 @@ def verify_load_fails(cur, data_file, err_msgs, exception=errors.DatabaseError):
23752375
cnx.close()
23762376
try:
23772377
os.remove(link)
2378-
except (FileNotFoundError):
2378+
except FileNotFoundError:
23792379
pass
23802380

23812381
# Clean up

tests/test_constants.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -68,7 +68,6 @@ def test_NET_BUFFER_LENGTH(self):
6868

6969

7070
class FieldTypeTests(tests.MySQLConnectorTests):
71-
7271
desc = {
7372
"DECIMAL": (0x00, "DECIMAL"),
7473
"TINY": (0x01, "TINY"),
@@ -194,7 +193,6 @@ def test_get_timestamp_types(self):
194193

195194

196195
class FieldFlagTests(tests.MySQLConnectorTests):
197-
198196
desc = {
199197
"NOT_NULL": (1 << 0, "Field can't be NULL"),
200198
"PRI_KEY": (1 << 1, "Field is part of a primary key"),
@@ -266,7 +264,6 @@ def test_get_bit_info(self):
266264

267265

268266
class ClientFlagTests(tests.MySQLConnectorTests):
269-
270267
desc = {
271268
"LONG_PASSWD": (1 << 0, "New more secure passwords"),
272269
"FOUND_ROWS": (1 << 1, "Found instead of affected rows"),
@@ -459,7 +456,6 @@ def test_get_supported(self):
459456

460457

461458
class SQLModesTests(tests.MySQLConnectorTests):
462-
463459
modes = (
464460
"REAL_AS_FLOAT",
465461
"PIPES_AS_CONCAT",

0 commit comments

Comments
 (0)