Skip to content

Commit 20a439f

Browse files
committed
line width fix
1 parent e1e6621 commit 20a439f

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

aiomysql/prepared_statement.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,28 @@ def _encode_params(self, args):
5757
elif isinstance(arg, Decimal):
5858
type_data += bytes([FIELD_TYPE.STRING, 0])
5959
data = str(arg).encode('utf-8')
60-
value_data += self._get_encoded_integer_on_length(len(data)) + data
60+
value_data += \
61+
self._get_encoded_integer_on_length(len(data)) + data
6162
elif isinstance(arg, bytes):
6263
type_data += bytes([FIELD_TYPE.STRING, 0])
63-
value_data += self._get_encoded_integer_on_length(len(arg)) + arg
64+
value_data += \
65+
self._get_encoded_integer_on_length(len(arg)) + arg
6466
elif isinstance(arg, str):
6567
type_data += bytes([FIELD_TYPE.STRING, 0])
6668
data = arg.encode("utf-8")
67-
value_data += self._get_encoded_integer_on_length(len(data)) + data
69+
value_data += \
70+
self._get_encoded_integer_on_length(len(data)) + data
6871
elif isinstance(arg, (datetime.date, datetime.datetime)):
6972
type_data += bytes([FIELD_TYPE.STRING, 0])
7073
data = arg.strftime("%Y-%m-%d %H:%M:%S.%f").encode('utf-8')
71-
value_data += self._get_encoded_integer_on_length(len(data)) + data
74+
value_data += \
75+
self._get_encoded_integer_on_length(len(data)) + data
7276
continue
7377
else:
7478
raise Error("unsupported type " + str(type(arg)))
75-
return bytes(null_bitmap) + new_params_bound_flag + type_data + value_data
79+
return (
80+
bytes(null_bitmap) + new_params_bound_flag + type_data + value_data
81+
)
7682

7783
async def fetchone(self):
7884
if self._rows is None:
@@ -113,7 +119,8 @@ async def _read_result(self):
113119
# read column definitions
114120
for _ in range(columns_num):
115121
# noinspection PyProtectedMember
116-
columns.append(await self.connection._read_packet(FieldDescriptorPacket))
122+
columns.append(
123+
await self.connection._read_packet(FieldDescriptorPacket))
117124
# noinspection PyProtectedMember
118125
packet = await self.connection._read_packet()
119126
if not packet.is_eof_packet():
@@ -149,9 +156,10 @@ def _get_encoded_integer_on_length(self, size):
149156

150157

151158
_string_types = {
152-
FIELD_TYPE.STRING, FIELD_TYPE.VARCHAR, FIELD_TYPE.VAR_STRING, FIELD_TYPE.ENUM,
153-
FIELD_TYPE.SET, FIELD_TYPE.LONG_BLOB, FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.BLOB,
154-
FIELD_TYPE.TINY_BLOB, FIELD_TYPE.GEOMETRY, FIELD_TYPE.BIT, FIELD_TYPE.DECIMAL,
159+
FIELD_TYPE.STRING, FIELD_TYPE.VARCHAR, FIELD_TYPE.VAR_STRING,
160+
FIELD_TYPE.ENUM, FIELD_TYPE.SET, FIELD_TYPE.LONG_BLOB,
161+
FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.BLOB, FIELD_TYPE.TINY_BLOB,
162+
FIELD_TYPE.GEOMETRY, FIELD_TYPE.BIT, FIELD_TYPE.DECIMAL,
155163
FIELD_TYPE.NEWDECIMAL, FIELD_TYPE.JSON,
156164
}
157165
_date_types = {
@@ -229,13 +237,15 @@ def get_result(self):
229237
second = self.read_uint8()
230238
if n == 7:
231239
result.append(
232-
datetime.datetime(year, month, day, hour, minute, second))
240+
datetime.datetime(
241+
year, month, day, hour, minute, second))
233242
continue
234243
microsecond = self.read_uint32()
235244
if n == 11:
236245
result.append(
237246
datetime.datetime(
238-
year, month, day, hour, minute, second, microsecond))
247+
year, month, day, hour, minute, second, microsecond
248+
))
239249
continue
240250
if c.type_code == FIELD_TYPE.TIME:
241251
n = self.read_uint8()
@@ -250,11 +260,13 @@ def get_result(self):
250260
minute = self.read_uint8()
251261
second = self.read_uint8()
252262
time_delta = datetime.timedelta(
253-
days=days, seconds=second, minutes=minute, hours=hour) * negate
263+
days=days, seconds=second, minutes=minute, hours=hour
264+
) * negate
254265
if n == 8:
255266
result.append(time_delta)
256267
continue
257-
time_delta += datetime.timedelta(microseconds=self.read_uint32())
268+
time_delta += \
269+
datetime.timedelta(microseconds=self.read_uint32())
258270
result.append(time_delta)
259271
continue
260272

tests/test_prepared_statement.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ async def test(connection):
6565
coldatetime,
6666
coltime,
6767
colint2
68-
) VALUES
68+
) VALUES
6969
(?,?,?,?,ST_GeomFromText('POINT(1 1)'),?,?,?,?,?,?,?,?,?,?,?,?,?)
7070
"""
7171
)
7272
await prepared.execute(
73-
"123", "a", b"\x01\x02", "b", 1, Decimal("123"), '{"a":"b"}', 123, 123, 123,
74-
123, 123.45, 123.45, datetime.date(2020, 6, 1),
73+
"123", "a", b"\x01\x02", "b", 1, Decimal("123"), '{"a":"b"}', 123, 123,
74+
123, 123, 123.45, 123.45, datetime.date(2020, 6, 1),
7575
datetime.datetime(2020, 6, 1, 1, 23, 45, 678),
7676
datetime.datetime(1, 1, 1, 1, 23, 45), None)
7777

0 commit comments

Comments
 (0)