Skip to content

Commit 6ff9a21

Browse files
committed
Lint hazelcast/protocol
Removed exclusion of `hazelcast/protocol` folder and linted the files there.
1 parent 048bd49 commit 6ff9a21

File tree

288 files changed

+2131
-446
lines changed

Some content is hidden

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

288 files changed

+2131
-446
lines changed

hazelcast/protocol/__init__.py

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ def __init__(self, error_code, class_name, message, stack_trace_elements):
1111
self.stack_trace_elements = stack_trace_elements
1212

1313
def __eq__(self, other):
14-
return isinstance(other, ErrorHolder) and self.error_code == other.error_code \
15-
and self.class_name == other.class_name and self.message == other.message \
16-
and self.stack_trace_elements == other.stack_trace_elements
14+
return (
15+
isinstance(other, ErrorHolder)
16+
and self.error_code == other.error_code
17+
and self.class_name == other.class_name
18+
and self.message == other.message
19+
and self.stack_trace_elements == other.stack_trace_elements
20+
)
1721

1822
def __ne__(self, other):
1923
return not self.__eq__(other)
@@ -29,9 +33,13 @@ def __init__(self, class_name, method_name, file_name, line_number):
2933
self.line_number = line_number
3034

3135
def __eq__(self, other):
32-
return isinstance(other, StackTraceElement) and self.class_name == other.class_name \
33-
and self.method_name == other.method_name and self.file_name == other.file_name \
34-
and self.line_number == other.line_number
36+
return (
37+
isinstance(other, StackTraceElement)
38+
and self.class_name == other.class_name
39+
and self.method_name == other.method_name
40+
and self.file_name == other.file_name
41+
and self.line_number == other.line_number
42+
)
3543

3644
def __ne__(self, other):
3745
return not self.__eq__(other)
@@ -53,10 +61,12 @@ def __init__(self, name, seed, group_id):
5361
self.id = group_id
5462

5563
def __eq__(self, other):
56-
return isinstance(other, RaftGroupId) \
57-
and self.name == other.name \
58-
and self.seed == other.seed \
59-
and self.id == other.id
64+
return (
65+
isinstance(other, RaftGroupId)
66+
and self.name == other.name
67+
and self.seed == other.seed
68+
and self.id == other.id
69+
)
6070

6171
def __ne__(self, other):
6272
return not self.__eq__(other)
@@ -90,11 +100,25 @@ def as_anchor_list(self, to_object):
90100

91101
class PagingPredicateHolder(object):
92102
__slots__ = (
93-
"anchor_data_list_holder", "predicate_data", "comparator_data", "page_size", "page", "iteration_type_id",
94-
"partition_key_data")
95-
96-
def __init__(self, anchor_data_list_holder, predicate_data, comparator_data, page_size, page, iteration_type_id,
97-
partition_key_data):
103+
"anchor_data_list_holder",
104+
"predicate_data",
105+
"comparator_data",
106+
"page_size",
107+
"page",
108+
"iteration_type_id",
109+
"partition_key_data",
110+
)
111+
112+
def __init__(
113+
self,
114+
anchor_data_list_holder,
115+
predicate_data,
116+
comparator_data,
117+
page_size,
118+
page,
119+
iteration_type_id,
120+
partition_key_data,
121+
):
98122
self.anchor_data_list_holder = anchor_data_list_holder
99123
self.predicate_data = predicate_data
100124
self.comparator_data = comparator_data
@@ -120,5 +144,12 @@ def of(predicate, to_data):
120144
comparator_data = to_data(predicate.comparator)
121145
iteration_type = predicate.iteration_type
122146

123-
return PagingPredicateHolder(anchor_data_list_holder, predicate_data, comparator_data, predicate.page_size,
124-
predicate.page, iteration_type, None)
147+
return PagingPredicateHolder(
148+
anchor_data_list_holder,
149+
predicate_data,
150+
comparator_data,
151+
predicate.page_size,
152+
predicate.page,
153+
iteration_type,
154+
None,
155+
)

hazelcast/protocol/builtin.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22

33
from hazelcast import six
44
from hazelcast.six.moves import range
5-
from hazelcast.protocol.client_message import NULL_FRAME_BUF, BEGIN_FRAME_BUF, END_FRAME_BUF, \
6-
SIZE_OF_FRAME_LENGTH_AND_FLAGS, _IS_FINAL_FLAG, NULL_FINAL_FRAME_BUF, END_FINAL_FRAME_BUF
7-
from hazelcast.serialization import LONG_SIZE_IN_BYTES, UUID_SIZE_IN_BYTES, LE_INT, LE_LONG, BOOLEAN_SIZE_IN_BYTES, \
8-
INT_SIZE_IN_BYTES, LE_ULONG, LE_UINT16, LE_INT8, UUID_MSB_SHIFT, UUID_LSB_MASK
5+
from hazelcast.protocol.client_message import (
6+
NULL_FRAME_BUF,
7+
BEGIN_FRAME_BUF,
8+
END_FRAME_BUF,
9+
SIZE_OF_FRAME_LENGTH_AND_FLAGS,
10+
_IS_FINAL_FLAG,
11+
NULL_FINAL_FRAME_BUF,
12+
END_FINAL_FRAME_BUF,
13+
)
14+
from hazelcast.serialization import (
15+
LONG_SIZE_IN_BYTES,
16+
UUID_SIZE_IN_BYTES,
17+
LE_INT,
18+
LE_LONG,
19+
BOOLEAN_SIZE_IN_BYTES,
20+
INT_SIZE_IN_BYTES,
21+
LE_ULONG,
22+
LE_UINT16,
23+
LE_INT8,
24+
UUID_MSB_SHIFT,
25+
UUID_LSB_MASK,
26+
)
927
from hazelcast.serialization.data import Data
1028

1129

@@ -145,7 +163,6 @@ def decode_nullable(msg, key_decoder, value_decoder):
145163

146164

147165
class EntryListUUIDLongCodec(object):
148-
149166
@staticmethod
150167
def encode(buf, entries, is_final=False):
151168
n = len(entries)
@@ -251,7 +268,10 @@ def decode_uuid(buf, offset):
251268

252269
msb_offset = offset + BOOLEAN_SIZE_IN_BYTES
253270
lsb_offset = msb_offset + LONG_SIZE_IN_BYTES
254-
b = buf[lsb_offset - 1:msb_offset - 1:-1] + buf[lsb_offset + LONG_SIZE_IN_BYTES - 1:lsb_offset - 1:-1]
271+
b = (
272+
buf[lsb_offset - 1 : msb_offset - 1 : -1]
273+
+ buf[lsb_offset + LONG_SIZE_IN_BYTES - 1 : lsb_offset - 1 : -1]
274+
)
255275
return uuid.UUID(bytes=bytes(b))
256276

257277

@@ -265,7 +285,9 @@ def encode(buf, arr, is_final=False):
265285
if is_final:
266286
LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
267287
for i in range(n):
268-
FixSizedTypesCodec.encode_int(b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * INT_SIZE_IN_BYTES, arr[i])
288+
FixSizedTypesCodec.encode_int(
289+
b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * INT_SIZE_IN_BYTES, arr[i]
290+
)
269291
buf.extend(b)
270292

271293
@staticmethod
@@ -288,7 +310,9 @@ def encode(buf, arr, is_final=False):
288310
if is_final:
289311
LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
290312
for i in range(n):
291-
FixSizedTypesCodec.encode_long(b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * LONG_SIZE_IN_BYTES, arr[i])
313+
FixSizedTypesCodec.encode_long(
314+
b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * LONG_SIZE_IN_BYTES, arr[i]
315+
)
292316
buf.extend(b)
293317

294318
@staticmethod
@@ -376,7 +400,9 @@ def encode(buf, arr, is_final=False):
376400
if is_final:
377401
LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
378402
for i in range(n):
379-
FixSizedTypesCodec.encode_uuid(b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * UUID_SIZE_IN_BYTES, arr[i])
403+
FixSizedTypesCodec.encode_uuid(
404+
b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * UUID_SIZE_IN_BYTES, arr[i]
405+
)
380406
buf.extend(b)
381407

382408
@staticmethod
@@ -399,7 +425,9 @@ def encode(buf, arr, is_final=False):
399425
if is_final:
400426
LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
401427
for i in range(n):
402-
FixSizedTypesCodec.encode_long(b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * LONG_SIZE_IN_BYTES, arr[i])
428+
FixSizedTypesCodec.encode_long(
429+
b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * LONG_SIZE_IN_BYTES, arr[i]
430+
)
403431
buf.extend(b)
404432

405433
@staticmethod

hazelcast/protocol/client_message.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ def set_backup_aware_flag(self):
9292
def __repr__(self):
9393
message_type = LE_INT.unpack_from(self.buf, _OUTBOUND_MESSAGE_MESSAGE_TYPE_OFFSET)[0]
9494
correlation_id = self.get_correlation_id()
95-
return "OutboundMessage(message_type=%s, correlation_id=%s, retryable=%s)" \
96-
% (message_type, correlation_id, self.retryable)
95+
return "OutboundMessage(message_type=%s, correlation_id=%s, retryable=%s)" % (
96+
message_type,
97+
correlation_id,
98+
self.retryable,
99+
)
97100

98101

99102
class Frame(object):
@@ -213,7 +216,9 @@ def __repr__(self):
213216
# Has END_DATA_STRUCTURE and IS_FINAL flags
214217
END_FINAL_FRAME_BUF = bytearray(SIZE_OF_FRAME_LENGTH_AND_FLAGS)
215218
LE_INT.pack_into(END_FINAL_FRAME_BUF, 0, SIZE_OF_FRAME_LENGTH_AND_FLAGS)
216-
LE_UINT16.pack_into(END_FINAL_FRAME_BUF, INT_SIZE_IN_BYTES, _END_DATA_STRUCTURE_FLAG | _IS_FINAL_FLAG)
219+
LE_UINT16.pack_into(
220+
END_FINAL_FRAME_BUF, INT_SIZE_IN_BYTES, _END_DATA_STRUCTURE_FLAG | _IS_FINAL_FLAG
221+
)
217222

218223

219224
class ClientMessageBuilder(object):

hazelcast/protocol/codec/atomic_long_add_and_get_codec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from hazelcast.serialization.bits import *
22
from hazelcast.protocol.builtin import FixSizedTypesCodec
3-
from hazelcast.protocol.client_message import OutboundMessage, REQUEST_HEADER_SIZE, create_initial_buffer, RESPONSE_HEADER_SIZE
3+
from hazelcast.protocol.client_message import (
4+
OutboundMessage,
5+
REQUEST_HEADER_SIZE,
6+
create_initial_buffer,
7+
RESPONSE_HEADER_SIZE,
8+
)
49
from hazelcast.protocol.codec.custom.raft_group_id_codec import RaftGroupIdCodec
510
from hazelcast.protocol.builtin import StringCodec
611

hazelcast/protocol/codec/atomic_long_alter_codec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from hazelcast.serialization.bits import *
22
from hazelcast.protocol.builtin import FixSizedTypesCodec
3-
from hazelcast.protocol.client_message import OutboundMessage, REQUEST_HEADER_SIZE, create_initial_buffer, RESPONSE_HEADER_SIZE
3+
from hazelcast.protocol.client_message import (
4+
OutboundMessage,
5+
REQUEST_HEADER_SIZE,
6+
create_initial_buffer,
7+
RESPONSE_HEADER_SIZE,
8+
)
49
from hazelcast.protocol.codec.custom.raft_group_id_codec import RaftGroupIdCodec
510
from hazelcast.protocol.builtin import StringCodec
611
from hazelcast.protocol.builtin import DataCodec

hazelcast/protocol/codec/atomic_long_apply_codec.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
from hazelcast.protocol.client_message import OutboundMessage, REQUEST_HEADER_SIZE, create_initial_buffer
1+
from hazelcast.protocol.client_message import (
2+
OutboundMessage,
3+
REQUEST_HEADER_SIZE,
4+
create_initial_buffer,
5+
)
26
from hazelcast.protocol.codec.custom.raft_group_id_codec import RaftGroupIdCodec
37
from hazelcast.protocol.builtin import StringCodec
48
from hazelcast.protocol.builtin import DataCodec

hazelcast/protocol/codec/atomic_long_compare_and_set_codec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from hazelcast.serialization.bits import *
22
from hazelcast.protocol.builtin import FixSizedTypesCodec
3-
from hazelcast.protocol.client_message import OutboundMessage, REQUEST_HEADER_SIZE, create_initial_buffer, RESPONSE_HEADER_SIZE
3+
from hazelcast.protocol.client_message import (
4+
OutboundMessage,
5+
REQUEST_HEADER_SIZE,
6+
create_initial_buffer,
7+
RESPONSE_HEADER_SIZE,
8+
)
49
from hazelcast.protocol.codec.custom.raft_group_id_codec import RaftGroupIdCodec
510
from hazelcast.protocol.builtin import StringCodec
611

hazelcast/protocol/codec/atomic_long_get_and_add_codec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from hazelcast.serialization.bits import *
22
from hazelcast.protocol.builtin import FixSizedTypesCodec
3-
from hazelcast.protocol.client_message import OutboundMessage, REQUEST_HEADER_SIZE, create_initial_buffer, RESPONSE_HEADER_SIZE
3+
from hazelcast.protocol.client_message import (
4+
OutboundMessage,
5+
REQUEST_HEADER_SIZE,
6+
create_initial_buffer,
7+
RESPONSE_HEADER_SIZE,
8+
)
49
from hazelcast.protocol.codec.custom.raft_group_id_codec import RaftGroupIdCodec
510
from hazelcast.protocol.builtin import StringCodec
611

hazelcast/protocol/codec/atomic_long_get_and_set_codec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from hazelcast.serialization.bits import *
22
from hazelcast.protocol.builtin import FixSizedTypesCodec
3-
from hazelcast.protocol.client_message import OutboundMessage, REQUEST_HEADER_SIZE, create_initial_buffer, RESPONSE_HEADER_SIZE
3+
from hazelcast.protocol.client_message import (
4+
OutboundMessage,
5+
REQUEST_HEADER_SIZE,
6+
create_initial_buffer,
7+
RESPONSE_HEADER_SIZE,
8+
)
49
from hazelcast.protocol.codec.custom.raft_group_id_codec import RaftGroupIdCodec
510
from hazelcast.protocol.builtin import StringCodec
611

hazelcast/protocol/codec/atomic_long_get_codec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
from hazelcast.protocol.builtin import FixSizedTypesCodec
2-
from hazelcast.protocol.client_message import OutboundMessage, REQUEST_HEADER_SIZE, create_initial_buffer, RESPONSE_HEADER_SIZE
2+
from hazelcast.protocol.client_message import (
3+
OutboundMessage,
4+
REQUEST_HEADER_SIZE,
5+
create_initial_buffer,
6+
RESPONSE_HEADER_SIZE,
7+
)
38
from hazelcast.protocol.codec.custom.raft_group_id_codec import RaftGroupIdCodec
49
from hazelcast.protocol.builtin import StringCodec
510

0 commit comments

Comments
 (0)