Skip to content

Commit 0778c83

Browse files
committed
Fix formatting to base.py
1 parent 7083c97 commit 0778c83

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

pymysqlreplication/tests/base.py

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# -*- coding: utf-8 -*-
22

3-
import pymysql
43
import copy
5-
6-
from pymysql.cursors import Cursor
7-
8-
from pymysqlreplication import BinLogStreamReader
94
import os
105
import sys
6+
import typing
7+
import pymysql
8+
9+
from pymysqlreplication import BinLogStreamReader
1110

1211
if sys.version_info < (2, 7):
1312
import unittest2 as unittest
1413
else:
1514
import unittest
1615

16+
if typing.TYPE_CHECKING:
17+
from pymysql.cursors import Cursor
18+
1719
base = unittest.TestCase
1820

1921

@@ -30,7 +32,7 @@ def setUp(self) -> None:
3032
"port": 3306,
3133
"use_unicode": True,
3234
"charset": "utf8",
33-
"db": "pymysqlreplication_test"
35+
"db": "pymysqlreplication_test",
3436
}
3537

3638
self.conn_control = None
@@ -50,25 +52,27 @@ def getMySQLVersion(self) -> str:
5052
"""Return the MySQL version of the server
5153
If version is 5.6.10-log the result is 5.6.10
5254
"""
53-
return self.execute("SELECT VERSION()").fetchone()[0].split('-')[0]
55+
return self.execute("SELECT VERSION()").fetchone()[0].split("-")[0]
5456

5557
def isMySQL56AndMore(self) -> bool:
56-
version = float(self.getMySQLVersion().rsplit('.', 1)[0])
58+
version = float(self.getMySQLVersion().rsplit(".", 1)[0])
5759
if version >= 5.6:
5860
return True
5961
return False
6062

6163
def isMySQL57(self) -> bool:
62-
version = float(self.getMySQLVersion().rsplit('.', 1)[0])
64+
version = float(self.getMySQLVersion().rsplit(".", 1)[0])
6365
return version == 5.7
6466

6567
def isMySQL80AndMore(self) -> bool:
66-
version = float(self.getMySQLVersion().rsplit('.', 1)[0])
68+
version = float(self.getMySQLVersion().rsplit(".", 1)[0])
6769
return version >= 8.0
6870

6971
def isMariaDB(self) -> bool:
7072
if self.__is_mariaDB is None:
71-
self.__is_mariaDB = "MariaDB" in self.execute("SELECT VERSION()").fetchone()[0]
73+
self.__is_mariaDB = (
74+
"MariaDB" in self.execute("SELECT VERSION()").fetchone()[0]
75+
)
7276
return self.__is_mariaDB
7377

7478
@property
@@ -92,7 +96,7 @@ def execute(self, query: str) -> Cursor:
9296
c = self.conn_control.cursor()
9397
c.execute(query)
9498
return c
95-
99+
96100
def execute_with_args(self, query: str, args) -> Cursor:
97101
c = self.conn_control.cursor()
98102
c.execute(query, args)
@@ -102,12 +106,13 @@ def resetBinLog(self) -> None:
102106
self.execute("RESET MASTER")
103107
if self.stream is not None:
104108
self.stream.close()
105-
self.stream = BinLogStreamReader(self.database, server_id=1024,
106-
ignored_events=self.ignoredEvents())
109+
self.stream = BinLogStreamReader(
110+
self.database, server_id=1024, ignored_events=self.ignoredEvents()
111+
)
107112

108113
def set_sql_mode(self) -> None:
109114
"""set sql_mode to test with same sql_mode (mysql 5.7 sql_mode default is changed)"""
110-
version = float(self.getMySQLVersion().rsplit('.', 1)[0])
115+
version = float(self.getMySQLVersion().rsplit(".", 1)[0])
111116
if version == 5.7:
112117
self.execute("SET @@sql_mode='NO_ENGINE_SUBSTITUTION'")
113118

@@ -118,7 +123,7 @@ def bin_log_format(self):
118123
return result[0]
119124

120125
def bin_log_basename(self) -> str:
121-
cursor: Cursor = self.execute('SELECT @@log_bin_basename')
126+
cursor: Cursor = self.execute("SELECT @@log_bin_basename")
122127
bin_log_basename = cursor.fetchone()[0]
123128
bin_log_basename = bin_log_basename.split("/")[-1]
124129
return bin_log_basename
@@ -134,7 +139,7 @@ def setUp(self) -> None:
134139
"port": int(os.environ.get("MARIADB_10_6_PORT") or 3308),
135140
"use_unicode": True,
136141
"charset": "utf8",
137-
"db": "pymysqlreplication_test"
142+
"db": "pymysqlreplication_test",
138143
}
139144

140145
self.conn_control = None
@@ -147,9 +152,9 @@ def setUp(self) -> None:
147152
self.connect_conn_control(db)
148153
self.stream = None
149154
self.resetBinLog()
150-
155+
151156
def bin_log_basename(self) -> str:
152-
cursor: Cursor = self.execute('SELECT @@log_bin_basename')
157+
cursor: Cursor = self.execute("SELECT @@log_bin_basename")
153158
bin_log_basename = cursor.fetchone()[0]
154159
bin_log_basename = bin_log_basename.split("/")[-1]
155160
return bin_log_basename

0 commit comments

Comments
 (0)