Skip to content

Commit e4740c3

Browse files
flake8: fix style
This patch includes fixes for all remaining cases of - E101 indentation contains mixed spaces and tabs, - E121 continuation line under-indented for hanging indent, - E122 continuation line missing indentation or outdented, - E123 closing bracket does not match indentation of opening bracket's line, - E124 closing bracket does not match visual indentation, - E126 continuation line over-indented for hanging indent, - E127 continuation line over-indented for visual indent, - E128 continuation line under-indented for visual indent, - E131 continuation line unaligned for hanging indent, - E201 whitespace after '(', - E202 whitespace before '(', - E203 Whitespace before ':', - E221 multiple spaces before operator, - E225 missing whitespace around operator, - E226 missing whitespace around arithmetic operator, - E227 missing whitespace around bitwise or shift, operator, - E231 missing whitespace after ',', ';', or ':', - E241 multiple spaces after ',', - E251 unexpected spaces around keyword / parameter equals, - E252 missing whitespace around parameter equals, - E261 at least two spaces before inline comment, - E275 missing whitespace after keyword, - E301 expected 1 blank line, - E302 expected 2 blank lines, - E303 too many blank lines, - E305 expected 2 blank lines after class or function definition, - E306 expected 1 blank line before a nested definition, - E502 the backslash is redundant between brackets, - W191 indentation contains tabs, - W293 blank line contains whitespace, - W504 line break after binary operator. Part of #270
1 parent f9b2136 commit e4740c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2340
-2342
lines changed

setup.py

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
cmdclass = {}
1414
command_options = {}
1515

16+
1617
class BuildPyCommand(build_py):
1718
"""
1819
Build the package
@@ -38,6 +39,7 @@ def run(self):
3839

3940
return super().run()
4041

42+
4143
cmdclass["build_py"] = BuildPyCommand
4244

4345
# Build Sphinx documentation (html)
@@ -68,6 +70,7 @@ def read(*parts):
6870
with codecs.open(filename, encoding='utf-8') as file:
6971
return file.read()
7072

73+
7174
def get_dependencies(filename):
7275
"""
7376
Get package dependencies from the `requirements.txt`.

tarantool/connection.py

+79-78
Large diffs are not rendered by default.

tarantool/connection_pool.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class PoolUnit():
161161
:type: :obj:`bool`
162162
"""
163163

164+
164165
# Based on https://realpython.com/python-interface/
165166
class StrategyInterface(metaclass=abc.ABCMeta):
166167
"""
@@ -169,13 +170,13 @@ class StrategyInterface(metaclass=abc.ABCMeta):
169170

170171
@classmethod
171172
def __subclasshook__(cls, subclass):
172-
return (hasattr(subclass, '__init__') and
173-
callable(subclass.__init__) and
174-
hasattr(subclass, 'update') and
175-
callable(subclass.update) and
176-
hasattr(subclass, 'getnext') and
177-
callable(subclass.getnext) or
178-
NotImplemented)
173+
return (hasattr(subclass, '__init__')
174+
and callable(subclass.__init__)
175+
and hasattr(subclass, 'update')
176+
and callable(subclass.update)
177+
and hasattr(subclass, 'getnext')
178+
and callable(subclass.getnext)
179+
or NotImplemented)
179180

180181
@abc.abstractmethod
181182
def __init__(self, pool):
@@ -204,6 +205,7 @@ def getnext(self, mode):
204205

205206
raise NotImplementedError
206207

208+
207209
class RoundRobinStrategy(StrategyInterface):
208210
"""
209211
Simple round-robin pool servers rotation.
@@ -500,7 +502,7 @@ def __init__(self,
500502
socket_timeout=socket_timeout,
501503
reconnect_max_attempts=reconnect_max_attempts,
502504
reconnect_delay=reconnect_delay,
503-
connect_now=False, # Connect in ConnectionPool.connect()
505+
connect_now=False, # Connect in ConnectionPool.connect()
504506
encoding=encoding,
505507
call_16=call_16,
506508
connection_timeout=connection_timeout,
@@ -650,7 +652,7 @@ def _request_process_loop(self, key, unit, last_refresh):
650652
method = getattr(Connection, task.method_name)
651653
try:
652654
resp = method(unit.conn, *task.args, **task.kwargs)
653-
except Exception as exc: # pylint: disable=broad-exception-caught,broad-except
655+
except Exception as exc: # pylint: disable=broad-exception-caught,broad-except
654656
unit.output_queue.put(exc)
655657
else:
656658
unit.output_queue.put(resp)
@@ -918,7 +920,7 @@ def upsert(self, space_name, tuple_value, op_list, *, index=0, mode=Mode.RW,
918920
"""
919921

920922
return self._send(mode, 'upsert', space_name, tuple_value,
921-
op_list, index=index, on_push=on_push, on_push_ctx=on_push_ctx)
923+
op_list, index=index, on_push=on_push, on_push_ctx=on_push_ctx)
922924

923925
def update(self, space_name, key, op_list, *, index=0, mode=Mode.RW,
924926
on_push=None, on_push_ctx=None):
@@ -955,7 +957,7 @@ def update(self, space_name, key, op_list, *, index=0, mode=Mode.RW,
955957
"""
956958

957959
return self._send(mode, 'update', space_name, key,
958-
op_list, index=index, on_push=on_push, on_push_ctx=on_push_ctx)
960+
op_list, index=index, on_push=on_push, on_push_ctx=on_push_ctx)
959961

960962
def ping(self, notime=False, *, mode=None):
961963
"""

tarantool/crud.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ def __init__(self, response):
3434
raise RuntimeError('Unable to decode response to object due to unknown type')
3535

3636

37-
class CrudResult(CrudResponse): # pylint: disable=too-few-public-methods
37+
class CrudResult(CrudResponse): # pylint: disable=too-few-public-methods
3838
"""
3939
Contains result's fields from result variable
4040
of crud module operation.
4141
"""
4242

4343

44-
class CrudError(CrudResponse): # pylint: disable=too-few-public-methods
44+
class CrudError(CrudResponse): # pylint: disable=too-few-public-methods
4545
"""
4646
Contains error's fields from error variable
4747
of crud module operation.

tarantool/dbapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
NotSupportedError,
1818
)
1919

20-
Warning = Warning # pylint: disable=redefined-builtin,self-assigning-variable
20+
Warning = Warning # pylint: disable=redefined-builtin,self-assigning-variable
2121

2222
# pylint: disable=invalid-name
2323
paramstyle = 'named'

tarantool/error.py

+8
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,21 @@ class ConfigurationError(Error):
111111
Error of initialization with a user-provided configuration.
112112
"""
113113

114+
114115
class MsgpackError(Error):
115116
"""
116117
Error with encoding or decoding of `MP_EXT`_ types.
117118
118119
.. _MP_EXT: https://www.tarantool.io/en/doc/latest/dev_guide/internals/msgpack_extensions/
119120
"""
120121

122+
121123
class MsgpackWarning(UserWarning):
122124
"""
123125
Warning with encoding or decoding of `MP_EXT`_ types.
124126
"""
125127

128+
126129
# Monkey patch os.strerror for win32
127130
if sys.platform == "win32":
128131
# Windows Sockets Error Codes (not all, but related on network errors)
@@ -267,6 +270,7 @@ class NetworkWarning(UserWarning):
267270
Warning related to network.
268271
"""
269272

273+
270274
class SslError(DatabaseError):
271275
"""
272276
Error related to SSL.
@@ -298,17 +302,20 @@ class ClusterDiscoveryWarning(UserWarning):
298302
Warning related to cluster discovery.
299303
"""
300304

305+
301306
class ClusterConnectWarning(UserWarning):
302307
"""
303308
Warning related to cluster pool connection.
304309
"""
305310

311+
306312
class PoolTolopogyWarning(UserWarning):
307313
"""
308314
Warning related to unsatisfying `box.info.ro`_ state of
309315
pool instances.
310316
"""
311317

318+
312319
class PoolTolopogyError(DatabaseError):
313320
"""
314321
Exception raised due to unsatisfying `box.info.ro`_ state of
@@ -317,6 +324,7 @@ class PoolTolopogyError(DatabaseError):
317324
.. _box.info.ro: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_info/
318325
"""
319326

327+
320328
class CrudModuleError(DatabaseError):
321329
"""
322330
Exception raised for errors that are related to

tarantool/mesh_connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def format_error(address, err):
155155
'port must be an int for an inet result')
156156
if result['port'] < 1 or result['port'] > 65535:
157157
return format_error(result, 'port must be in range [1, 65535] '
158-
'for an inet result')
158+
'for an inet result')
159159

160160
# Looks okay.
161161
return result, None

tarantool/msgpack_ext/datetime.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353

5454
BYTEORDER = 'little'
5555

56-
SECONDS_SIZE_BYTES = 8
57-
NSEC_SIZE_BYTES = 4
56+
SECONDS_SIZE_BYTES = 8
57+
NSEC_SIZE_BYTES = 4
5858
TZOFFSET_SIZE_BYTES = 2
59-
TZINDEX_SIZE_BYTES = 2
59+
TZINDEX_SIZE_BYTES = 2
6060

6161

6262
def get_int_as_bytes(data, size):
@@ -77,6 +77,7 @@ def get_int_as_bytes(data, size):
7777

7878
return data.to_bytes(size, byteorder=BYTEORDER, signed=True)
7979

80+
8081
def encode(obj, _):
8182
"""
8283
Encode a datetime object.
@@ -133,6 +134,7 @@ def get_bytes_as_int(data, cursor, size):
133134
part = data[cursor:cursor + size]
134135
return int.from_bytes(part, BYTEORDER, signed=True), cursor + size
135136

137+
136138
def decode(data, _):
137139
"""
138140
Decode a datetime object.
@@ -151,11 +153,11 @@ def decode(data, _):
151153
seconds, cursor = get_bytes_as_int(data, cursor, SECONDS_SIZE_BYTES)
152154

153155
data_len = len(data)
154-
if data_len == (SECONDS_SIZE_BYTES + NSEC_SIZE_BYTES + \
155-
TZOFFSET_SIZE_BYTES + TZINDEX_SIZE_BYTES):
156-
nsec, cursor = get_bytes_as_int(data, cursor, NSEC_SIZE_BYTES)
156+
if data_len == (SECONDS_SIZE_BYTES + NSEC_SIZE_BYTES
157+
+ TZOFFSET_SIZE_BYTES + TZINDEX_SIZE_BYTES):
158+
nsec, cursor = get_bytes_as_int(data, cursor, NSEC_SIZE_BYTES)
157159
tzoffset, cursor = get_bytes_as_int(data, cursor, TZOFFSET_SIZE_BYTES)
158-
tzindex, cursor = get_bytes_as_int(data, cursor, TZINDEX_SIZE_BYTES)
160+
tzindex, cursor = get_bytes_as_int(data, cursor, TZINDEX_SIZE_BYTES)
159161
elif data_len == SECONDS_SIZE_BYTES:
160162
nsec = 0
161163
tzoffset = 0

tarantool/msgpack_ext/decimal.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
TARANTOOL_DECIMAL_MAX_DIGITS = 38
6767

68+
6869
def get_mp_sign(sign):
6970
"""
7071
Parse decimal sign to a nibble.
@@ -88,6 +89,7 @@ def get_mp_sign(sign):
8889

8990
raise RuntimeError
9091

92+
9193
def add_mp_digit(digit, bytes_reverted, digit_count):
9294
"""
9395
Append decimal digit to a binary data array.
@@ -109,6 +111,7 @@ def add_mp_digit(digit, bytes_reverted, digit_count):
109111
else:
110112
bytes_reverted.append(digit)
111113

114+
112115
def check_valid_tarantool_decimal(str_repr, scale, first_digit_ind):
113116
"""
114117
Decimal numbers have 38 digits of precision, that is, the total
@@ -183,21 +186,21 @@ def check_valid_tarantool_decimal(str_repr, scale, first_digit_ind):
183186
return True
184187

185188
if (digit_count - scale) > TARANTOOL_DECIMAL_MAX_DIGITS:
186-
raise MsgpackError('Decimal cannot be encoded: Tarantool decimal ' + \
189+
raise MsgpackError('Decimal cannot be encoded: Tarantool decimal '
187190
'supports a maximum of 38 digits.')
188191

189192
starts_with_zero = str_repr[first_digit_ind] == '0'
190193

191-
if ( (digit_count > TARANTOOL_DECIMAL_MAX_DIGITS + 1) or \
192-
(digit_count == TARANTOOL_DECIMAL_MAX_DIGITS + 1 \
193-
and not starts_with_zero)):
194-
warn('Decimal encoded with loss of precision: ' + \
194+
if (digit_count > TARANTOOL_DECIMAL_MAX_DIGITS + 1) or \
195+
(digit_count == TARANTOOL_DECIMAL_MAX_DIGITS + 1 and not starts_with_zero):
196+
warn('Decimal encoded with loss of precision: '
195197
'Tarantool decimal supports a maximum of 38 digits.',
196198
MsgpackWarning)
197199
return False
198200

199201
return True
200202

203+
201204
def strip_decimal_str(str_repr, scale, first_digit_ind):
202205
"""
203206
Strip decimal digits after the decimal point if decimal cannot be
@@ -225,6 +228,7 @@ def strip_decimal_str(str_repr, scale, first_digit_ind):
225228
# Do not strips zeroes before the decimal point
226229
return str_repr
227230

231+
228232
def encode(obj, _):
229233
"""
230234
Encode a decimal object.
@@ -308,6 +312,7 @@ def get_str_sign(nibble):
308312

309313
raise MsgpackError('Unexpected MP_DECIMAL sign nibble')
310314

315+
311316
def add_str_digit(digit, digits_reverted, scale):
312317
"""
313318
Append decimal digit to a binary data array.
@@ -334,6 +339,7 @@ def add_str_digit(digit, digits_reverted, scale):
334339

335340
digits_reverted.append(str(digit))
336341

342+
337343
def decode(data, _):
338344
"""
339345
Decode a decimal object.

tarantool/msgpack_ext/error.py

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
`error`_ type id.
1717
"""
1818

19+
1920
def encode(obj, packer):
2021
"""
2122
Encode an error object.
@@ -33,6 +34,7 @@ def encode(obj, packer):
3334
err_map = encode_box_error(obj)
3435
return packer.pack(err_map)
3536

37+
3638
def decode(data, unpacker):
3739
"""
3840
Decode an error object.

tarantool/msgpack_ext/interval.py

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
`datetime.interval`_ type id.
5252
"""
5353

54+
5455
def encode(obj, _):
5556
"""
5657
Encode an interval object.
@@ -79,6 +80,7 @@ def encode(obj, _):
7980

8081
return buf
8182

83+
8284
def decode(data, unpacker):
8385
"""
8486
Decode an interval object.

tarantool/msgpack_ext/packer.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
import tarantool.msgpack_ext.interval as ext_interval
2020

2121
encoders = [
22-
{'type': Decimal, 'ext': ext_decimal },
23-
{'type': UUID, 'ext': ext_uuid },
24-
{'type': BoxError, 'ext': ext_error },
22+
{'type': Decimal, 'ext': ext_decimal},
23+
{'type': UUID, 'ext': ext_uuid},
24+
{'type': BoxError, 'ext': ext_error},
2525
{'type': Datetime, 'ext': ext_datetime},
2626
{'type': Interval, 'ext': ext_interval},
2727
]
2828

29+
2930
def default(obj, packer=None):
3031
"""
3132
:class:`msgpack.Packer` encoder.

0 commit comments

Comments
 (0)