tango-python 1.18.1__py3-none-any.whl → 1.18.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.
tango/__init__.py CHANGED
@@ -62,7 +62,7 @@ from .webhooks import (
62
62
  )
63
63
  from .webhooks.receiver import Delivery, WebhookReceiver
64
64
 
65
- __version__ = "1.18.1"
65
+ __version__ = "1.18.2"
66
66
  __all__ = [
67
67
  "TangoClient",
68
68
  "TangoAPIError",
tango/exceptions.py CHANGED
@@ -1,7 +1,11 @@
1
1
  """Tango API exceptions"""
2
2
 
3
+ import re
3
4
  from typing import Any
4
5
 
6
+ # The API names the tripped rate in its 429 detail: "Rate limit exceeded for daily. Please try again in 16 hours, 58 minutes."
7
+ _RATE_NAME = re.compile(r"exceeded for ([\w-]+)", re.IGNORECASE)
8
+
5
9
 
6
10
  class TangoAPIError(Exception):
7
11
  """Base exception for Tango API errors"""
@@ -88,11 +92,13 @@ class TangoRateLimitError(TangoAPIError):
88
92
  d = self.detail
89
93
  if not d:
90
94
  return None
91
- lower = d.lower()
92
- if "burst" in lower or "minute" in lower:
93
- return "burst"
94
- if "daily" in lower or "day" in lower:
95
+ # Read the rate's name, not the whole sentence: a daily lockout's wait reads "16 hours, 58 minutes", which a match on "minute" took for burst.
96
+ match = _RATE_NAME.search(d)
97
+ text = match.group(1).lower() if match else d.lower()
98
+ if "daily" in text or re.search(r"\bday\b", text):
95
99
  return "daily"
100
+ if "burst" in text or "minute" in text:
101
+ return "burst"
96
102
  return None
97
103
 
98
104
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tango-python
3
- Version: 1.18.1
3
+ Version: 1.18.2
4
4
  Summary: Python SDK for the Tango API
5
5
  Project-URL: Homepage, https://github.com/makegov/tango-python
6
6
  Project-URL: Documentation, https://docs.makegov.com/tango-python
@@ -1,6 +1,6 @@
1
- tango/__init__.py,sha256=VqhIYcfNI56Lx8iBaT3qGYKpjaHxLWPpTC-fIujYxQA,2739
1
+ tango/__init__.py,sha256=EcmM-sPf6gUtZML4RQbgS31RPAi4oz91N6XIIvpRjbk,2739
2
2
  tango/client.py,sha256=awauFCq-gd-dCBAvDPeEBBgxwhuc_2ZzIhK-I7ki0U8,245711
3
- tango/exceptions.py,sha256=oPiLCccBoWLK5SjHkzP-oI6mUD9twEeKSvEuLV5h01I,4224
3
+ tango/exceptions.py,sha256=TL2MrSbcy99ogrJugLiP1I5J5qNih770knISycDTx-g,4661
4
4
  tango/models.py,sha256=D9e8_AAAwVi1C4nOqdhWz-8ARBLPRsLGi8TDjucOMEY,72897
5
5
  tango/shapes/__init__.py,sha256=7ea1WU74jp4znhNw-gXruag6m6eyPZtbVgbDFmFUWro,1072
6
6
  tango/shapes/explicit_schemas.py,sha256=fwjHiFLOMpFyNLNM4M6kdK603s-t8gxHYqcSeL3jz7g,85674
@@ -16,8 +16,8 @@ tango/webhooks/cli.py,sha256=f_vQbJ2AeSQjKnQo7MxHFyUB2SAKcgHYmGQULS0isqQ,13858
16
16
  tango/webhooks/receiver.py,sha256=5yhsVhlLyoxmOCGvmbynWAIlDB2OaCPVf1H4GA1SxmU,9279
17
17
  tango/webhooks/signing.py,sha256=92Ee-0B6PR7ZkvY3Np3gzl88-mtfKkh-I7lxqCe2lGw,2374
18
18
  tango/webhooks/simulate.py,sha256=g2Osa0FYU5mJuon07T2aUCtmkUoTEzsY261tlp76fF0,3165
19
- tango_python-1.18.1.dist-info/METADATA,sha256=WL8McHrCjg-DuQ2-9FLyb9DyQZge8oSMnNXFCQhY_Nw,22824
20
- tango_python-1.18.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
21
- tango_python-1.18.1.dist-info/entry_points.txt,sha256=kGLUbglUjuaAqEFvOZ1QuSW0vWb6VeSpCIFKaOFkKoQ,50
22
- tango_python-1.18.1.dist-info/licenses/LICENSE,sha256=j2kYVHMwTkoGn3ZNScnrdIueG0k2XzB_LCPFoyBc2wk,1064
23
- tango_python-1.18.1.dist-info/RECORD,,
19
+ tango_python-1.18.2.dist-info/METADATA,sha256=0kfKbSpvkJVxOpXsF7jerdb3dDyqc81PSAxbQRPN8fQ,22824
20
+ tango_python-1.18.2.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
21
+ tango_python-1.18.2.dist-info/entry_points.txt,sha256=kGLUbglUjuaAqEFvOZ1QuSW0vWb6VeSpCIFKaOFkKoQ,50
22
+ tango_python-1.18.2.dist-info/licenses/LICENSE,sha256=j2kYVHMwTkoGn3ZNScnrdIueG0k2XzB_LCPFoyBc2wk,1064
23
+ tango_python-1.18.2.dist-info/RECORD,,