python-sendparcel 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_sendparcel-0.3.1.dist-info → python_sendparcel-0.3.2.dist-info}/METADATA +1 -1
- {python_sendparcel-0.3.1.dist-info → python_sendparcel-0.3.2.dist-info}/RECORD +6 -6
- {python_sendparcel-0.3.1.dist-info → python_sendparcel-0.3.2.dist-info}/WHEEL +1 -1
- sendparcel/flow.py +17 -11
- sendparcel/providers/dummy.py +21 -2
- {python_sendparcel-0.3.1.dist-info → python_sendparcel-0.3.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-sendparcel
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Framework-agnostic parcel shipping core for Python.
|
|
5
5
|
Project-URL: Homepage, https://github.com/python-sendparcel/python-sendparcel
|
|
6
6
|
Project-URL: Repository, https://github.com/python-sendparcel/python-sendparcel
|
|
@@ -4,7 +4,7 @@ sendparcel/concurrent.py,sha256=RFkuIjL9XehDqBc2cHXivbzYlJtR_9ZxjAqO5_hxJzY,2082
|
|
|
4
4
|
sendparcel/enums.py,sha256=e1UM9ka5zWJg4naMCoVeUrIy_PVPPEYHOBh6XiXaW4Q,687
|
|
5
5
|
sendparcel/exceptions.py,sha256=zC5_o9oQfNuOBKaiw5csaHAJmhYsZc3WVbOaoq7s1W0,1437
|
|
6
6
|
sendparcel/factory.py,sha256=VVB8Kz3J-7QI-VjrJsMwKso5SVZf97yZBX5nMbnCMM4,1045
|
|
7
|
-
sendparcel/flow.py,sha256=
|
|
7
|
+
sendparcel/flow.py,sha256=4ANkO2G0QSFoXl6oZ6DYQfrTato-oR-cZ9lKJfGkuE4,13490
|
|
8
8
|
sendparcel/fsm.py,sha256=bRkt8tj_mg71Wq8obhhKK6nrQuN2a4Y_YXiL7kYxPDU,3134
|
|
9
9
|
sendparcel/logging.py,sha256=TOetzdKJtl6YIY9Dpq-uxWB-jituOEKx0DpWmGrrBMU,4256
|
|
10
10
|
sendparcel/protocols.py,sha256=7YX2KTOEG5Nje6bzibmIODFiTX7tgqb6I3WYgx9uVS4,2344
|
|
@@ -13,8 +13,8 @@ sendparcel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
13
13
|
sendparcel/registry.py,sha256=CCaU7Esd6vS5eVvvv_oLuWEhd9j17Zk3-hEOZl-_7Vk,3790
|
|
14
14
|
sendparcel/types.py,sha256=E96qcbQ6qfpvtA-LRdIzQounYXDWnfMNZJypzJ3dI1g,4855
|
|
15
15
|
sendparcel/providers/__init__.py,sha256=ff82dvrWuPS-UIGF5AoX_fgpcYZaGu2k6q2yrxMZacI,192
|
|
16
|
-
sendparcel/providers/dummy.py,sha256=
|
|
17
|
-
python_sendparcel-0.3.
|
|
18
|
-
python_sendparcel-0.3.
|
|
19
|
-
python_sendparcel-0.3.
|
|
20
|
-
python_sendparcel-0.3.
|
|
16
|
+
sendparcel/providers/dummy.py,sha256=NHQIdeKEPzZeLEMKxT82Jzj7KvBat_gvpQeJ6KBTvI4,3557
|
|
17
|
+
python_sendparcel-0.3.2.dist-info/METADATA,sha256=-R_wb54oqM5qNoFRtyEFsWWLH2xMzZ12GW27XpKnm_4,7175
|
|
18
|
+
python_sendparcel-0.3.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
19
|
+
python_sendparcel-0.3.2.dist-info/licenses/LICENSE,sha256=IZXSBOjgGvChgayLmtTnU40iE7hsrrU3WVEYKx0sywY,1075
|
|
20
|
+
python_sendparcel-0.3.2.dist-info/RECORD,,
|
sendparcel/flow.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from dataclasses import dataclass
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any, cast
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
@@ -227,7 +227,10 @@ class ShipmentFlow:
|
|
|
227
227
|
- ``AUTH_ERROR`` → re-raises provider auth error.
|
|
228
228
|
"""
|
|
229
229
|
provider = self._get_provider(shipment)
|
|
230
|
-
outcome =
|
|
230
|
+
outcome = cast(
|
|
231
|
+
"CancelOutcome",
|
|
232
|
+
await self._call_provider(provider.cancel_shipment(**kwargs)),
|
|
233
|
+
)
|
|
231
234
|
if outcome.get("reason") == CancelReason.TRANSIENT_ERROR:
|
|
232
235
|
raise CommunicationError(
|
|
233
236
|
outcome.get("detail") or "Cancel failed with transient error",
|
|
@@ -281,15 +284,18 @@ class ShipmentFlow:
|
|
|
281
284
|
provider_class,
|
|
282
285
|
provider_config,
|
|
283
286
|
)
|
|
284
|
-
return
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
287
|
+
return cast(
|
|
288
|
+
"list[PickupPoint]",
|
|
289
|
+
await self._call_provider(
|
|
290
|
+
provider.search_points(
|
|
291
|
+
query=query,
|
|
292
|
+
near=near,
|
|
293
|
+
radius_m=radius_m,
|
|
294
|
+
point_type=point_type,
|
|
295
|
+
limit=limit,
|
|
296
|
+
**kwargs,
|
|
297
|
+
)
|
|
298
|
+
),
|
|
293
299
|
)
|
|
294
300
|
|
|
295
301
|
def _get_provider(self, shipment: Shipment) -> BaseProvider:
|
sendparcel/providers/dummy.py
CHANGED
|
@@ -12,6 +12,8 @@ from sendparcel.provider import BaseProvider
|
|
|
12
12
|
from sendparcel.types import (
|
|
13
13
|
AddressInfo,
|
|
14
14
|
CallbackContext,
|
|
15
|
+
CancelOutcome,
|
|
16
|
+
CancelReason,
|
|
15
17
|
LabelInfo,
|
|
16
18
|
ParcelInfo,
|
|
17
19
|
ShipmentCreateResult,
|
|
@@ -78,6 +80,23 @@ class DummyProvider(BaseProvider):
|
|
|
78
80
|
status=self.get_setting("status_override", self.shipment.status)
|
|
79
81
|
)
|
|
80
82
|
|
|
81
|
-
async def cancel_shipment(self, **kwargs: Any) ->
|
|
83
|
+
async def cancel_shipment(self, **kwargs: Any) -> CancelOutcome:
|
|
84
|
+
"""Cancel with a configurable structured outcome.
|
|
85
|
+
|
|
86
|
+
Settings: ``cancel_success`` (bool, default True) and
|
|
87
|
+
``cancel_reason`` (a :class:`CancelReason` value used when the
|
|
88
|
+
cancel is configured to fail; defaults to ``not_cancellable``).
|
|
89
|
+
"""
|
|
82
90
|
await self._simulate_latency()
|
|
83
|
-
|
|
91
|
+
if bool(self.get_setting("cancel_success", True)):
|
|
92
|
+
return CancelOutcome(
|
|
93
|
+
cancelled=True, reason=CancelReason.CANCELLED, retryable=False
|
|
94
|
+
)
|
|
95
|
+
reason = CancelReason(
|
|
96
|
+
self.get_setting("cancel_reason", CancelReason.NOT_CANCELLABLE)
|
|
97
|
+
)
|
|
98
|
+
return CancelOutcome(
|
|
99
|
+
cancelled=False,
|
|
100
|
+
reason=reason,
|
|
101
|
+
retryable=reason == CancelReason.TRANSIENT_ERROR,
|
|
102
|
+
)
|
|
File without changes
|