Skip to content

Commit 14d1fe4

Browse files
authored
Enh/code revamp 3 (#24)
* Better order for _method usage in _service_request * Use tuple instead of frozenset with responses that have entities list * Fix docstring in BaseResponseMeta
1 parent 05537ba commit 14d1fe4

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/abstract_api/core/bases/_base_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BaseResponseMeta(ABC):
88
"""Base response metadata for Abstract API service response."""
99

1010
def __init__(self, response: requests.models.Response) -> None:
11-
"""Initialize a new ResponseMeta."""
11+
"""Initialize a new BaseResponseMeta."""
1212
self._http_status: int = response.status_code
1313
self._body: bytes = response.content
1414

src/abstract_api/core/bases/base_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def _service_request(
7272
Returns:
7373
Parsed AbstractAPI's response.
7474
"""
75-
if _method.lower() not in ["get", "post"]:
75+
_method = _method.lower()
76+
if _method not in ["get", "post"]:
7677
raise ClientRequestError(
7778
f"Invalid or not allowed HTTP method '{_method}'"
7879
)
@@ -82,7 +83,6 @@ def _service_request(
8283
"url": self._service_url(_action)
8384
}
8485

85-
_method = _method.lower()
8686
if _method == "get":
8787
request_kwargs["params"] = {"api_key": self._api_key} | params
8888
else:

src/abstract_api/exchange_rates/_multiple_exchange_rates_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _init_response_field(self, field: str, value: Any) -> None:
4141
exchange_rates.append(
4242
ExchangeRate(currency=currency, rate=rate)
4343
)
44-
value = frozenset(exchange_rates)
44+
value = tuple(exchange_rates)
4545
super()._init_response_field(field, value)
4646

4747
@property
@@ -50,6 +50,6 @@ def base(self) -> str | None:
5050
return self._get_response_field("base")
5151

5252
@property
53-
def exchange_rates(self) -> frozenset[ExchangeRate] | None:
53+
def exchange_rates(self) -> tuple[ExchangeRate] | None:
5454
"""Target currencies exchange rates versus the base currency."""
5555
return self._get_response_field("exchange_rates")

src/abstract_api/holidays/holidays_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ def _init_response_field(
134134
holidays = []
135135
for c in value:
136136
holidays.append(Holiday(**c))
137-
self._holidays = frozenset(holidays)
137+
self._holidays = tuple(holidays)
138138

139139
def __init__(self, response: requests.models.Response) -> None:
140140
"""Initializes a new HolidaysResponse."""
141141
super().__init__(response, RESPONSE_FIELDS, list_response=True)
142142

143143
@property
144-
def holidays(self) -> frozenset[Holiday]:
144+
def holidays(self) -> tuple[Holiday]:
145145
"""The returned holidays."""
146146
return self._get_response_field("holidays")

src/abstract_api/vat/vat_categories_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _init_response_field(
6767
categories = []
6868
for c in value:
6969
categories.append(Category(**c))
70-
self._categories = frozenset(categories)
70+
self._categories = tuple(categories)
7171

7272
def __init__(self, response: requests.models.Response) -> None:
7373
"""Initializes a new VATCategoriesResponse."""
@@ -78,6 +78,6 @@ def __init__(self, response: requests.models.Response) -> None:
7878
)
7979

8080
@property
81-
def categories(self) -> frozenset[Category] | None:
81+
def categories(self) -> tuple[Category] | None:
8282
"""The returned VAT categories."""
8383
return self._get_response_field("categories")

0 commit comments

Comments
 (0)