Skip to content

Commit a003364

Browse files
committed
formatting
1 parent aaa7fbe commit a003364

File tree

9 files changed

+80
-73
lines changed

9 files changed

+80
-73
lines changed

examples/getting_started/getting_started.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ def __init__(self):
2525
self._count = 0
2626

2727
def on_amqp_message(self, event: Event):
28-
print("received message: {} ".format(Converter.bytes_to_string(event.message.body)))
28+
print(
29+
"received message: {} ".format(
30+
Converter.bytes_to_string(event.message.body)
31+
)
32+
)
2933

3034
# accepting
3135
self.delivery_context.accept(event)

examples/oauth/oaut.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def main() -> None:
144144

145145
# publish 10 messages
146146
for i in range(MESSAGES_TO_PUBLISH):
147-
status = publisher.publish(Message(body=Converter.string_to_bytes("test_{}".format(i))))
147+
status = publisher.publish(
148+
Message(body=Converter.string_to_bytes("test_{}".format(i)))
149+
)
148150
if status.remote_state == OutcomeState.ACCEPTED:
149151
print("message: test_{} accepted".format(i))
150152
elif status.remote_state == OutcomeState.RELEASED:

examples/reconnection/reconnection_example.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def __init__(self):
2929

3030
def on_message(self, event: Event):
3131
if self._count % 1000 == 0:
32-
print("received 100 message: " + Converter.bytes_to_string(event.message.body))
32+
print(
33+
"received 100 message: " + Converter.bytes_to_string(event.message.body)
34+
)
3335

3436
# accepting
3537
self.delivery_context.accept(event)

rabbitmq_amqp_python_client/connection.py

-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ def dial(self) -> None:
180180
self._ssl_domain = SSLDomain(SSLDomain.MODE_CLIENT)
181181
assert self._ssl_domain
182182

183-
184183
if isinstance(self._conf_ssl_context, PosixSslConfigurationContext):
185184
ca_cert = self._conf_ssl_context.ca_cert
186185
elif isinstance(self._conf_ssl_context, WinSslConfigurationContext):

rabbitmq_amqp_python_client/management.py

+35-35
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ def close(self) -> None:
9898
self._receiver.close()
9999

100100
def request(
101-
self,
102-
body: Any,
103-
path: str,
104-
method: str,
105-
expected_response_codes: list[int],
101+
self,
102+
body: Any,
103+
path: str,
104+
method: str,
105+
expected_response_codes: list[int],
106106
) -> Message:
107107
"""
108108
Send a management request with a new UUID.
@@ -124,12 +124,12 @@ def request(
124124
)
125125

126126
def _request(
127-
self,
128-
id: str,
129-
body: Any,
130-
path: str,
131-
method: str,
132-
expected_response_codes: list[int],
127+
self,
128+
id: str,
129+
body: Any,
130+
path: str,
131+
method: str,
132+
expected_response_codes: list[int],
133133
) -> Message:
134134
amq_message = Message(
135135
id=id,
@@ -152,10 +152,10 @@ def _request(
152152
return msg
153153

154154
def declare_exchange(
155-
self,
156-
exchange_specification: Union[
157-
ExchangeSpecification, ExchangeCustomSpecification
158-
],
155+
self,
156+
exchange_specification: Union[
157+
ExchangeSpecification, ExchangeCustomSpecification
158+
],
159159
) -> Union[ExchangeSpecification, ExchangeCustomSpecification]:
160160
"""
161161
Declare a new exchange in RabbitMQ.
@@ -196,10 +196,10 @@ def declare_exchange(
196196
return exchange_specification
197197

198198
def declare_queue(
199-
self,
200-
queue_specification: Union[
201-
ClassicQueueSpecification, QuorumQueueSpecification, StreamSpecification
202-
],
199+
self,
200+
queue_specification: Union[
201+
ClassicQueueSpecification, QuorumQueueSpecification, StreamSpecification
202+
],
203203
) -> Union[
204204
ClassicQueueSpecification, QuorumQueueSpecification, StreamSpecification
205205
]:
@@ -220,7 +220,7 @@ def declare_queue(
220220
logger.debug("declare_queue operation called")
221221

222222
if isinstance(queue_specification, ClassicQueueSpecification) or isinstance(
223-
queue_specification, QuorumQueueSpecification
223+
queue_specification, QuorumQueueSpecification
224224
):
225225
body = self._declare_queue(queue_specification)
226226

@@ -243,8 +243,8 @@ def declare_queue(
243243
return queue_specification
244244

245245
def _declare_queue(
246-
self,
247-
queue_specification: Union[ClassicQueueSpecification, QuorumQueueSpecification],
246+
self,
247+
queue_specification: Union[ClassicQueueSpecification, QuorumQueueSpecification],
248248
) -> dict[str, Any]:
249249

250250
body = {}
@@ -312,7 +312,7 @@ def _declare_queue(
312312
return body
313313

314314
def _declare_stream(
315-
self, stream_specification: StreamSpecification
315+
self, stream_specification: StreamSpecification
316316
) -> dict[str, Any]:
317317

318318
body = {}
@@ -325,7 +325,7 @@ def _declare_stream(
325325

326326
if stream_specification.max_age is not None:
327327
args["x-max-age"] = (
328-
str(int(stream_specification.max_age.total_seconds())) + "s"
328+
str(int(stream_specification.max_age.total_seconds())) + "s"
329329
)
330330

331331
if stream_specification.stream_max_segment_size_bytes is not None:
@@ -393,7 +393,7 @@ def delete_queue(self, name: str) -> None:
393393
)
394394

395395
def _validate_reponse_code(
396-
self, response_code: int, expected_response_codes: list[int]
396+
self, response_code: int, expected_response_codes: list[int]
397397
) -> None:
398398
if response_code == CommonValues.response_code_409.value:
399399
raise ValidationCodeException("ErrPreconditionFailed")
@@ -407,10 +407,10 @@ def _validate_reponse_code(
407407
)
408408

409409
def bind(
410-
self,
411-
bind_specification: Union[
412-
ExchangeToQueueBindingSpecification, ExchangeToExchangeBindingSpecification
413-
],
410+
self,
411+
bind_specification: Union[
412+
ExchangeToQueueBindingSpecification, ExchangeToExchangeBindingSpecification
413+
],
414414
) -> str:
415415
"""
416416
Create a binding between exchanges or between an exchange and a queue.
@@ -463,12 +463,12 @@ def bind(
463463
return binding_path
464464

465465
def unbind(
466-
self,
467-
bind_specification: Union[
468-
str,
469-
ExchangeToQueueBindingSpecification,
470-
ExchangeToExchangeBindingSpecification,
471-
],
466+
self,
467+
bind_specification: Union[
468+
str,
469+
ExchangeToQueueBindingSpecification,
470+
ExchangeToExchangeBindingSpecification,
471+
],
472472
) -> None:
473473
"""
474474
Remove a binding between exchanges or between an exchange and a queue.

rabbitmq_amqp_python_client/publisher.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ def publish(self, message: Message) -> Delivery:
8686
)
8787

8888
if not message.inferred:
89-
raise ArgumentOutOfRangeException(
90-
"Message inferred must be True"
91-
)
89+
raise ArgumentOutOfRangeException("Message inferred must be True")
9290

9391
if self._addr != "":
9492
if self._sender is not None:

rabbitmq_amqp_python_client/qpid/proton/_message.py

+24-24
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ class Message(object):
113113
DEFAULT_PRIORITY = PN_DEFAULT_PRIORITY
114114
""" Default AMQP message priority"""
115115

116-
def __init__(self, body: Union[str, bytes, dict, None] = None, inferred = True, **kwargs) -> None:
116+
def __init__(
117+
self, body: Union[str, bytes, dict, None] = None, inferred=True, **kwargs
118+
) -> None:
117119
# validate the types
118120

119121
self._msg = pn_message()
@@ -123,7 +125,6 @@ def __init__(self, body: Union[str, bytes, dict, None] = None, inferred = True,
123125
self.body = body
124126
self.inferred = inferred
125127

126-
127128
for k, v in kwargs.items():
128129
getattr(self, k) # Raise exception if it's not a valid attribute.
129130
setattr(self, k, v)
@@ -507,7 +508,7 @@ def instructions(self) -> Optional[AnnotationDict]:
507508

508509
@instructions.setter
509510
def instructions(
510-
self, instructions: Optional[Dict[Union[str, int], "PythonAMQPData"]]
511+
self, instructions: Optional[Dict[Union[str, int], "PythonAMQPData"]]
511512
) -> None:
512513
if isinstance(instructions, dict):
513514
self.instruction_dict = AnnotationDict(instructions, raise_on_error=False)
@@ -530,7 +531,7 @@ def annotations(self) -> Optional[AnnotationDict]:
530531

531532
@annotations.setter
532533
def annotations(
533-
self, annotations: Optional[Dict[Union[str, int], "PythonAMQPData"]]
534+
self, annotations: Optional[Dict[Union[str, int], "PythonAMQPData"]]
534535
) -> None:
535536
if isinstance(annotations, dict):
536537
self.annotation_dict = AnnotationDict(annotations, raise_on_error=False)
@@ -597,8 +598,7 @@ def send(self, sender: "Sender", tag: Optional[str] = None) -> "Delivery":
597598
return dlv
598599

599600
@overload
600-
def recv(self, link: "Sender") -> None:
601-
...
601+
def recv(self, link: "Sender") -> None: ...
602602

603603
def recv(self, link: "Receiver") -> Optional["Delivery"]:
604604
"""
@@ -629,24 +629,24 @@ def recv(self, link: "Receiver") -> Optional["Delivery"]:
629629
def __repr__(self) -> str:
630630
props = []
631631
for attr in (
632-
"inferred",
633-
"address",
634-
"reply_to",
635-
"durable",
636-
"ttl",
637-
"priority",
638-
"first_acquirer",
639-
"delivery_count",
640-
"id",
641-
"correlation_id",
642-
"user_id",
643-
"group_id",
644-
"group_sequence",
645-
"reply_to_group_id",
646-
"instructions",
647-
"annotations",
648-
"properties",
649-
"body",
632+
"inferred",
633+
"address",
634+
"reply_to",
635+
"durable",
636+
"ttl",
637+
"priority",
638+
"first_acquirer",
639+
"delivery_count",
640+
"id",
641+
"correlation_id",
642+
"user_id",
643+
"group_id",
644+
"group_sequence",
645+
"reply_to_group_id",
646+
"instructions",
647+
"annotations",
648+
"properties",
649+
"body",
650650
):
651651
value = getattr(self, attr)
652652
if value:

tests/test_connection.py

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def test_connection_ssl(ssl_context) -> None:
3838
environment = Environment(
3939
"amqps://guest:guest@localhost:5671/",
4040
ssl_context=ssl_context,
41-
4241
)
4342
path = Path(ssl_context.ca_cert)
4443
assert path.is_file() is True

tests/utils.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121

2222
def publish_messages(
23-
connection: Connection,
24-
messages_to_send: int,
25-
queue_name,
26-
filters: Optional[list[str]] = None,
23+
connection: Connection,
24+
messages_to_send: int,
25+
queue_name,
26+
filters: Optional[list[str]] = None,
2727
) -> None:
2828
annotations = {}
2929
if filters is not None:
@@ -34,7 +34,10 @@ def publish_messages(
3434
# publish messages_to_send messages
3535
for i in range(messages_to_send):
3636
publisher.publish(
37-
Message(body=Converter.string_to_bytes("test{}".format(i)), annotations=annotations)
37+
Message(
38+
body=Converter.string_to_bytes("test{}".format(i)),
39+
annotations=annotations,
40+
)
3841
)
3942
publisher.close()
4043

@@ -72,7 +75,7 @@ def setup_dead_lettering(management: Management) -> str:
7275

7376

7477
def create_binding(
75-
management: Management, exchange_name: str, queue_name: str, routing_key: str
78+
management: Management, exchange_name: str, queue_name: str, routing_key: str
7679
) -> str:
7780
management.declare_exchange(ExchangeSpecification(name=exchange_name))
7881

0 commit comments

Comments
 (0)