From 40c312464e26e5e13fba0ecc2e64c0c69d6f2c9d Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:28:05 -0700 Subject: [PATCH 1/4] fix: regenerate_rates return type --- easypost/services/shipment_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easypost/services/shipment_service.py b/easypost/services/shipment_service.py index aa85bc9..409eb7b 100644 --- a/easypost/services/shipment_service.py +++ b/easypost/services/shipment_service.py @@ -72,7 +72,7 @@ def get_next_page( return self.all(**params) - def regenerate_rates(self, id: str) -> Shipment: + def regenerate_rates(self, id: str) -> Dict[str, List[Rate]]: """Regenerate Rates for a Shipment.""" url = f"{self._instance_url(self._model_class, id)}/rerate" From 3e326d2fd4b082d8ad81581a2cc2c4b7ba8ce31f Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:29:47 -0700 Subject: [PATCH 2/4] fix: changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cafa414..0a51673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v9.0.1 (2023-12-20) + +- Corrects the return type of `regenerate_rates` + ## v9.0.0 (2023-12-06) See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-8x-to-90) for more details. From a765612093c20c5415602991bd316f88e3ea76c2 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:28:22 -0700 Subject: [PATCH 3/4] fix: allow for bare dicts to get_lowest_object_rate function --- easypost/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/easypost/util.py b/easypost/util.py index b46555c..d3ee927 100644 --- a/easypost/util.py +++ b/easypost/util.py @@ -7,6 +7,7 @@ Dict, List, Optional, + Union, ) from easypost.constant import ( @@ -24,10 +25,11 @@ InvalidParameterError, SignatureVerificationError, ) +from easypost.models.rate import Rate def get_lowest_object_rate( - easypost_object: EasyPostObject, + easypost_object: Union[EasyPostObject, Dict[str, Any]], carriers: Optional[List[str]] = None, services: Optional[List[str]] = None, rates_key: str = "rates", @@ -53,7 +55,7 @@ def get_lowest_object_rate( return lowest_rate -def get_lowest_smart_rate(smart_rates, delivery_days: int, delivery_accuracy: str): +def get_lowest_smart_rate(smart_rates: List[Rate], delivery_days: int, delivery_accuracy: str): """Get the lowest SmartRate from a list of SmartRates.""" valid_delivery_accuracy_values = { "percentile_50", From ed631c87e4cc1b88dbd48a9217c70f6763482d20 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:36:33 -0700 Subject: [PATCH 4/4] fix: add missing Rate return types --- easypost/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/easypost/util.py b/easypost/util.py index d3ee927..31a81ea 100644 --- a/easypost/util.py +++ b/easypost/util.py @@ -33,7 +33,7 @@ def get_lowest_object_rate( carriers: Optional[List[str]] = None, services: Optional[List[str]] = None, rates_key: str = "rates", -): +) -> Rate: """Gets the lowest rate of an EasyPost object such as a Shipment, Order, or Pickup.""" carriers = carriers or [] services = services or [] @@ -55,7 +55,7 @@ def get_lowest_object_rate( return lowest_rate -def get_lowest_smart_rate(smart_rates: List[Rate], delivery_days: int, delivery_accuracy: str): +def get_lowest_smart_rate(smart_rates: List[Rate], delivery_days: int, delivery_accuracy: str) -> Rate: """Get the lowest SmartRate from a list of SmartRates.""" valid_delivery_accuracy_values = { "percentile_50",