Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit ddc63c6

Browse files
author
Jesse Claven
authored
Merge pull request #89 from duffelhq/use-f-strings
Use f-strings everywhere [FLAPI-2162]
2 parents 907d4a8 + d78d017 commit ddc63c6

File tree

14 files changed

+21
-39
lines changed

14 files changed

+21
-39
lines changed

duffel_api/api/booking/offer_requests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ def __init__(self, **kwargs):
1515

1616
def get(self, id_):
1717
"""GET /air/offer_requests/:id"""
18-
return OfferRequest.from_json(
19-
self.do_get("{}/{}".format(self._url, id_))["data"]
20-
)
18+
return OfferRequest.from_json(self.do_get(f"{self._url}/{id_}")["data"])
2119

2220
def list(self, limit=50):
2321
"""GET /air/offer_requests"""

duffel_api/api/booking/offers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get(self, id_, return_available_services=False):
7070
if return_available_services:
7171
params["return_available_services"] = "true"
7272
return Offer.from_json(
73-
self.do_get("{}/{}".format(self._url, id_), query_params=params)["data"]
73+
self.do_get(f"{self._url}/{id_}", query_params=params)["data"]
7474
)
7575

7676
def list(self, offer_request_id, sort=None, max_connections=None, limit=50):

duffel_api/api/booking/order_cancellations.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def __init__(self, **kwargs):
2020

2121
def get(self, id_):
2222
"""GET /air/order_cancellations/:id."""
23-
return OrderCancellation.from_json(
24-
self.do_get("{}/{}".format(self._url, id_))["data"]
25-
)
23+
return OrderCancellation.from_json(self.do_get(f"{self._url}/{id_}")["data"])
2624

2725
def list(self, order_id, limit=50):
2826
"""Retrieve a paginated list of order cancellations."""
@@ -55,5 +53,5 @@ def confirm(self, id_):
5553
your customer (e.g. back to their credit/debit card).
5654
5755
"""
58-
url = "{}/{}/actions/confirm".format(self._url, id_)
56+
url = f"{self._url}/{id_}/actions/confirm"
5957
return OrderCancellation.from_json(self.do_post(url)["data"])

duffel_api/api/booking/order_change_offers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ def __init__(self, **kwargs):
1111

1212
def get(self, id_):
1313
"""GET /air/order_change_offers/:id"""
14-
return OrderChangeOffer.from_json(
15-
self.do_get("{}/{}".format(self._url, id_))["data"]
16-
)
14+
return OrderChangeOffer.from_json(self.do_get(f"{self._url}/{id_}")["data"])
1715

1816
def list(self, order_change_request_id, sort=None, max_connections=None, limit=50):
1917
"""GET /air/order_change_offers"""

duffel_api/api/booking/order_change_requests.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ def create(self, order_id):
1616

1717
def get(self, id_):
1818
"""GET /air/order_change_requests/:id"""
19-
return OrderChangeRequest.from_json(
20-
self.do_get("{}/{}".format(self._url, id_))["data"]
21-
)
19+
return OrderChangeRequest.from_json(self.do_get(f"{self._url}/{id_}")["data"])
2220

2321

2422
class OrderChangeRequestCreate:

duffel_api/api/booking/order_changes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def __init__(self, **kwargs):
2626

2727
def get(self, id_):
2828
"""GET /air/order_changes/:id."""
29-
return OrderChange.from_json(
30-
self.do_get("{}/{}".format(self._url, id_))["data"]
31-
)
29+
return OrderChange.from_json(self.do_get(f"{self._url}/{id_}")["data"])
3230

3331
def create(self, selected_order_change_offer):
3432
"""Create a pending order change.
@@ -64,7 +62,7 @@ def confirm(self, id_, payment_):
6462
"""
6563
OrderChangeClient._validate_payment(payment_)
6664

67-
url = "{}/{}/actions/confirm".format(self._url, id_)
65+
url = f"{self._url}/{id_}/actions/confirm"
6866

6967
res = self.do_post(
7068
url,

duffel_api/api/booking/orders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, **kwargs):
1515

1616
def get(self, id_):
1717
"""GET /air/orders/:id."""
18-
return Order.from_json(self.do_get("{}/{}".format(self._url, id_))["data"])
18+
return Order.from_json(self.do_get(f"{self._url}/{id_}")["data"])
1919

2020
def list(self, awaiting_payment=False, sort=None, limit=50):
2121
"""GET /air/orders."""

duffel_api/api/duffel_payments/payment_intents.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def get(self, id_):
2626
You should use this API to get the complete, up-to-date information
2727
about a Payment Intent.
2828
"""
29-
return PaymentIntent.from_json(
30-
self.do_get("{}/{}".format(self._url, id_))["data"]
31-
)
29+
return PaymentIntent.from_json(self.do_get(f"{self._url}/{id_}")["data"])
3230

3331
def confirm(self, id_):
3432
"""Confirm a Payment Intent
@@ -40,7 +38,7 @@ def confirm(self, id_):
4038
Once confirmed, the amount charged to your customer's card will be added
4139
to your Balance (minus any Duffel Payment fees).
4240
"""
43-
url = "{}/{}/actions/confirm".format(self._url, id_)
41+
url = f"{self._url}/{id_}/actions/confirm"
4442
return PaymentIntent.from_json(self.do_post(url)["data"])
4543

4644

duffel_api/api/notifications/webhooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def ping(self, id_):
2828
2929
Send a ping, a "fake event" notification, to a webhook.
3030
"""
31-
url = "{}/{}/actions/ping".format(self._url, id_)
31+
url = f"{self._url}/{id_}/actions/ping"
3232
self.do_post(url)
3333
return None
3434

@@ -72,7 +72,7 @@ def active(self, active):
7272

7373
def execute(self):
7474
"""PATCH /air/webhooks/{id}"""
75-
url = "{}/{}".format(self._client._url, self._id)
75+
url = f"{self._client._url}/{self._id}"
7676

7777
res = self._client.do_patch(
7878
url,

duffel_api/api/supporting/aircraft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, **kwargs):
1111

1212
def get(self, id_):
1313
"""GET /air/aircraft/:id"""
14-
return Aircraft.from_json(self.do_get("{}/{}".format(self._url, id_))["data"])
14+
return Aircraft.from_json(self.do_get(f"{self._url}/{id_}")["data"])
1515

1616
def list(self, limit=50):
1717
"""GET /air/aircraft"""

0 commit comments

Comments
 (0)