diff --git a/mercadopago/resources/advanced_payment.py b/mercadopago/resources/advanced_payment.py index 1a342c4..cb0314d 100644 --- a/mercadopago/resources/advanced_payment.py +++ b/mercadopago/resources/advanced_payment.py @@ -3,8 +3,8 @@ Wraps ``/v1/advanced_payments`` endpoints used in marketplace split-payment scenarios where funds are distributed among multiple receivers. -`API reference -`_ (advanced_payments section not found in current reference) +`API reference `_ +(advanced_payments section not found in current reference) """ from datetime import datetime @@ -30,8 +30,11 @@ def search(self, filters=None, request_options=None): Returns: dict: Paginated list of matching advanced payments. """ - return self._get(uri="/v1/advanced_payments/search", filters=filters, - request_options=request_options) + return self._get( + uri="/v1/advanced_payments/search", + filters=filters, + request_options=request_options, + ) def get(self, advanced_payment_id, request_options=None): """Retrieves an advanced payment by its ID. diff --git a/mercadopago/resources/order.py b/mercadopago/resources/order.py index 1a42f92..9c15479 100644 --- a/mercadopago/resources/order.py +++ b/mercadopago/resources/order.py @@ -95,7 +95,10 @@ def process(self, order_id, request_options=None): if not isinstance(order_id, str): raise ValueError("Param order_id must be a string") - return self._post(uri="/v1/orders/" + str(order_id) + "/process", request_options=request_options) # pylint: disable=line-too-long + return self._post( + uri=f"/v1/orders/{order_id}/process", + request_options=request_options, + ) def cancel(self, order_id, request_options=None): """Cancels an existing order. @@ -117,7 +120,10 @@ def cancel(self, order_id, request_options=None): if not isinstance(order_id, str): raise ValueError("Param order_id must be a string") - return self._post(uri="/v1/orders/" + str(order_id) + "/cancel", request_options=request_options) # pylint: disable=line-too-long + return self._post( + uri=f"/v1/orders/{order_id}/cancel", + request_options=request_options, + ) def capture(self, order_id, request_options=None): """Captures a previously authorised order. @@ -141,7 +147,10 @@ def capture(self, order_id, request_options=None): if not isinstance(order_id, str): raise ValueError("Param order_id must be a string") - return self._post(uri="/v1/orders/" + str(order_id) + "/capture", request_options=request_options) # pylint: disable=line-too-long + return self._post( + uri=f"/v1/orders/{order_id}/capture", + request_options=request_options, + ) def create_transaction(self, order_id, transaction_object, request_options=None): """Adds a payment transaction to an existing order. @@ -165,7 +174,9 @@ def create_transaction(self, order_id, transaction_object, request_options=None) return self._post(uri=f"/v1/orders/{order_id}/transactions", data=transaction_object, request_options=request_options) - def update_transaction(self, order_id, transaction_id, transaction_object, request_options=None): # pylint: disable=line-too-long + def update_transaction( + self, order_id, transaction_id, transaction_object, request_options=None + ): """Updates a transaction within an order. Args: diff --git a/mercadopago/webhook/validator.py b/mercadopago/webhook/validator.py index 415db64..835b569 100644 --- a/mercadopago/webhook/validator.py +++ b/mercadopago/webhook/validator.py @@ -63,7 +63,7 @@ def __init__(self, reason, request_id=None, timestamp=None): request_id: ``x-request-id`` value associated with the request. timestamp: ``ts`` extracted from the header, if available. """ - super().__init__("Invalid webhook signature: {0}".format(reason.value)) + super().__init__(f"Invalid webhook signature: {reason.value}") self.reason = reason self.request_id = request_id self.timestamp = timestamp @@ -73,7 +73,7 @@ def __init__(self, reason, request_id=None, timestamp=None): _VERSION_KEY_REGEX = re.compile(r"^v\d+$") -class WebhookSignatureValidator: +class WebhookSignatureValidator: # pylint: disable=too-few-public-methods """Stateless utility that validates the signature of a MercadoPago webhook. On failure :func:`validate` raises :class:`InvalidWebhookSignatureError`; @@ -85,11 +85,12 @@ class WebhookSignatureValidator: """ @staticmethod - def validate( + def validate( # pylint: disable=too-many-arguments x_signature, x_request_id, data_id, secret, + *, tolerance_seconds=None, supported_versions=None, now=None, @@ -130,7 +131,8 @@ def validate( data_id = _normalize(data_id) versions = tuple(supported_versions) if supported_versions else _DEFAULT_SUPPORTED_VERSIONS if now is None: - now = lambda: int(time.time() * 1000) + def now(): + return int(time.time() * 1000) if x_signature is None: raise InvalidWebhookSignatureError( @@ -214,8 +216,8 @@ def _build_manifest(data_id, request_id, ts): """Builds the HMAC manifest, omitting empty pairs per the documented rule.""" parts = [] if data_id: - parts.append("id:{0}".format(data_id.lower())) + parts.append(f"id:{data_id.lower()}") if request_id: - parts.append("request-id:{0}".format(request_id)) - parts.append("ts:{0}".format(ts)) + parts.append(f"request-id:{request_id}") + parts.append(f"ts:{ts}") return ";".join(parts) + ";" diff --git a/setup.cfg b/setup.cfg index 7fb9b53..4a36bf8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,7 @@ py-version = 3.9 [pylint.FORMAT] max-line-length = 100 +ignore-long-lines = ^\s*((`[^`]*`?\s+)??`?_?|Reference:\s+https?://\S+)(\s+.*)?$ [isort] # Vertical Hanging Indent