tango-python 1.17.0__py3-none-any.whl → 1.18.1__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.17.0"
65
+ __version__ = "1.18.1"
66
66
  __all__ = [
67
67
  "TangoClient",
68
68
  "TangoAPIError",
tango/client.py CHANGED
@@ -75,6 +75,31 @@ from tango.shapes import (
75
75
  _COUNT_TYPE_KEY = "_tango_count_type"
76
76
 
77
77
 
78
+ def _error_body(response: httpx.Response) -> dict[str, Any]:
79
+ """The JSON object an error response carries, or {} for an empty, non-JSON (a proxy's HTML page) or non-object body."""
80
+ try:
81
+ data = response.json() if response.content else {}
82
+ except ValueError:
83
+ return {}
84
+ return data if isinstance(data, dict) else {}
85
+
86
+
87
+ def _error_reason(error_data: dict[str, Any]) -> str | None:
88
+ """The server's own explanation from an error body, e.g. why a 403 refused the request.
89
+
90
+ The API sends either ``{"detail": "..."}`` or a structured body such as a tier gate's ``{"error": "...", "code": "tier_required", ...}``, sometimes nested under ``detail``.
91
+ """
92
+ for body in (error_data, error_data.get("detail")):
93
+ if isinstance(body, str) and body:
94
+ return body
95
+ if isinstance(body, dict):
96
+ for key in ("error", "message", "detail"):
97
+ value = body.get(key)
98
+ if isinstance(value, str) and value:
99
+ return value
100
+ return None
101
+
102
+
78
103
  class TangoClient:
79
104
  """Tango API Client"""
80
105
 
@@ -232,8 +257,13 @@ class TangoClient:
232
257
  detail = error_data.get("detail", "Rate limit exceeded")
233
258
  raise TangoRateLimitError(detail, response.status_code, error_data)
234
259
  elif not response.is_success:
260
+ error_data = _error_body(response)
261
+ reason = _error_reason(error_data)
262
+ message = f"API request failed with status {response.status_code}"
235
263
  raise TangoAPIError(
236
- f"API request failed with status {response.status_code}", response.status_code
264
+ f"{message}: {reason}" if reason else message,
265
+ response.status_code,
266
+ error_data,
237
267
  )
238
268
 
239
269
  def _get(self, endpoint: str, params: dict[str, Any] | None = None) -> dict[str, Any]:
@@ -695,7 +725,7 @@ class TangoClient:
695
725
  naics_code: NAICS code (mapped to 'naics' API param)
696
726
  psc_code: PSC code (mapped to 'psc' API param)
697
727
  recipient_name: Vendor/recipient name (mapped to 'recipient' API param)
698
- recipient_uei: Vendor UEI (mapped to 'uei' API param)
728
+ recipient_uei: Vendor UEI (mapped to 'uei' API param); join several with `|` for OR, up to 500
699
729
  set_aside_type: Set-aside type (mapped to 'set_aside' API param)
700
730
  sort: Field to sort by (combined with 'order' to produce 'ordering')
701
731
  order: Sort order ('asc' or 'desc', default 'asc')
tango/models.py CHANGED
@@ -281,6 +281,17 @@ class AwardTransaction:
281
281
  obligated: Decimal | None = None
282
282
 
283
283
 
284
+ @dataclass
285
+ class FiscalYearObligation:
286
+ """Schema definition for FiscalYearObligation (not used for instances).
287
+
288
+ One entry of an award's ``obligations_by_fiscal_year``: the obligations dated in one federal fiscal year, rounded to cents.
289
+ """
290
+
291
+ fiscal_year: int
292
+ obligated: Decimal
293
+
294
+
284
295
  @dataclass
285
296
  class OrganizationOfficePayload:
286
297
  """Schema definition for OrganizationOfficePayload (not used for instances).
@@ -197,6 +197,12 @@ TRANSACTION_SCHEMA: dict[str, FieldSchema] = {
197
197
  }
198
198
 
199
199
 
200
+ FISCAL_YEAR_OBLIGATION_SCHEMA: dict[str, FieldSchema] = {
201
+ "fiscal_year": FieldSchema(name="fiscal_year", type=int, is_optional=False, is_list=False),
202
+ "obligated": FieldSchema(name="obligated", type=Decimal, is_optional=False, is_list=False),
203
+ }
204
+
205
+
200
206
  DEPARTMENT_SCHEMA: dict[str, FieldSchema] = {
201
207
  "abbreviation": FieldSchema(name="abbreviation", type=str, is_optional=True, is_list=False),
202
208
  "code": FieldSchema(name="code", type=int, is_optional=True, is_list=False),
@@ -432,6 +438,13 @@ CONTRACT_SCHEMA: dict[str, FieldSchema] = {
432
438
  is_list=False,
433
439
  nested_model="Vehicle",
434
440
  ),
441
+ "obligations_by_fiscal_year": FieldSchema(
442
+ name="obligations_by_fiscal_year",
443
+ type=dict,
444
+ is_optional=True,
445
+ is_list=True,
446
+ nested_model="FiscalYearObligation",
447
+ ),
435
448
  }
436
449
 
437
450
 
@@ -1290,6 +1303,13 @@ IDV_SCHEMA: dict[str, FieldSchema] = {
1290
1303
  "idv_contracts_value": FieldSchema(
1291
1304
  name="idv_contracts_value", type=Decimal, is_optional=True, is_list=False
1292
1305
  ),
1306
+ "obligations_by_fiscal_year": FieldSchema(
1307
+ name="obligations_by_fiscal_year",
1308
+ type=dict,
1309
+ is_optional=True,
1310
+ is_list=True,
1311
+ nested_model="FiscalYearObligation",
1312
+ ),
1293
1313
  }
1294
1314
 
1295
1315
 
@@ -1439,6 +1459,13 @@ OTA_SCHEMA: dict[str, FieldSchema] = {
1439
1459
  is_list=False,
1440
1460
  nested_model="RecipientProfile",
1441
1461
  ),
1462
+ "obligations_by_fiscal_year": FieldSchema(
1463
+ name="obligations_by_fiscal_year",
1464
+ type=dict,
1465
+ is_optional=True,
1466
+ is_list=True,
1467
+ nested_model="FiscalYearObligation",
1468
+ ),
1442
1469
  }
1443
1470
 
1444
1471
  # OTIDV (Other Transaction IDV) - IDV-like
@@ -1459,6 +1486,13 @@ OTIDV_SCHEMA: dict[str, FieldSchema] = {
1459
1486
  is_list=False,
1460
1487
  nested_model="RecipientProfile",
1461
1488
  ),
1489
+ "obligations_by_fiscal_year": FieldSchema(
1490
+ name="obligations_by_fiscal_year",
1491
+ type=dict,
1492
+ is_optional=True,
1493
+ is_list=True,
1494
+ nested_model="FiscalYearObligation",
1495
+ ),
1462
1496
  }
1463
1497
 
1464
1498
  # Subaward (prime/sub awards)
@@ -1707,6 +1741,7 @@ EXPLICIT_SCHEMAS: dict[str, dict[str, FieldSchema]] = {
1707
1741
  "LegislativeMandates": LEGISLATIVE_MANDATES_SCHEMA,
1708
1742
  "SubawardsSummary": SUBAWARDS_SUMMARY_SCHEMA,
1709
1743
  "Transaction": TRANSACTION_SCHEMA,
1744
+ "FiscalYearObligation": FISCAL_YEAR_OBLIGATION_SCHEMA,
1710
1745
  "Department": DEPARTMENT_SCHEMA,
1711
1746
  "Contact": CONTACT_SCHEMA,
1712
1747
  "RecipientProfile": RECIPIENT_PROFILE_SCHEMA,
@@ -85,6 +85,9 @@ ATTACHMENTS_SCHEMA: dict[str, FieldSchema] = {
85
85
  "doc_role": FieldSchema(name="doc_role", type=str, is_optional=True, is_list=False),
86
86
  "doc_role_alt": FieldSchema(name="doc_role_alt", type=str, is_optional=True, is_list=False),
87
87
  "extracted_text": FieldSchema(name="extracted_text", type=str, is_optional=True, is_list=False),
88
+ "extraction_status": FieldSchema(
89
+ name="extraction_status", type=str, is_optional=True, is_list=False
90
+ ),
88
91
  "file_size": FieldSchema(name="file_size", type=int, is_optional=True, is_list=False),
89
92
  "mime_type": FieldSchema(name="mime_type", type=str, is_optional=True, is_list=False),
90
93
  "name": FieldSchema(name="name", type=str, is_optional=True, is_list=False),
@@ -99,6 +102,9 @@ ATTACHMENTS2_SCHEMA: dict[str, FieldSchema] = {
99
102
  "doc_role": FieldSchema(name="doc_role", type=str, is_optional=True, is_list=False),
100
103
  "doc_role_alt": FieldSchema(name="doc_role_alt", type=str, is_optional=True, is_list=False),
101
104
  "extracted_text": FieldSchema(name="extracted_text", type=str, is_optional=True, is_list=False),
105
+ "extraction_status": FieldSchema(
106
+ name="extraction_status", type=str, is_optional=True, is_list=False
107
+ ),
102
108
  "file_size": FieldSchema(name="file_size", type=int, is_optional=True, is_list=False),
103
109
  "mime_type": FieldSchema(name="mime_type", type=str, is_optional=True, is_list=False),
104
110
  "name": FieldSchema(name="name", type=str, is_optional=True, is_list=False),
@@ -135,6 +141,9 @@ ATTACHMENTS3_SCHEMA: dict[str, FieldSchema] = {
135
141
 
136
142
  ATTACHMENTS4_SCHEMA: dict[str, FieldSchema] = {
137
143
  "attachment_id": FieldSchema(name="attachment_id", type=str, is_optional=True, is_list=False),
144
+ "extraction_status": FieldSchema(
145
+ name="extraction_status", type=str, is_optional=True, is_list=False
146
+ ),
138
147
  "file_size": FieldSchema(name="file_size", type=str, is_optional=True, is_list=False),
139
148
  "mime_type": FieldSchema(name="mime_type", type=str, is_optional=True, is_list=False),
140
149
  "name": FieldSchema(name="name", type=str, is_optional=True, is_list=False),
@@ -149,6 +158,9 @@ ATTACHMENTS5_SCHEMA: dict[str, FieldSchema] = {
149
158
  "doc_role": FieldSchema(name="doc_role", type=str, is_optional=True, is_list=False),
150
159
  "doc_role_alt": FieldSchema(name="doc_role_alt", type=str, is_optional=True, is_list=False),
151
160
  "extracted_text": FieldSchema(name="extracted_text", type=str, is_optional=True, is_list=False),
161
+ "extraction_status": FieldSchema(
162
+ name="extraction_status", type=str, is_optional=True, is_list=False
163
+ ),
152
164
  "file_size": FieldSchema(name="file_size", type=str, is_optional=True, is_list=False),
153
165
  "mime_type": FieldSchema(name="mime_type", type=str, is_optional=True, is_list=False),
154
166
  "name": FieldSchema(name="name", type=str, is_optional=True, is_list=False),
@@ -758,6 +770,11 @@ NOTICE_TYPE_SCHEMA: dict[str, FieldSchema] = {
758
770
  "type": FieldSchema(name="type", type=str, is_optional=True, is_list=False),
759
771
  }
760
772
 
773
+ OBLIGATIONS_BY_FISCAL_YEAR_SCHEMA: dict[str, FieldSchema] = {
774
+ "fiscal_year": FieldSchema(name="fiscal_year", type=str, is_optional=True, is_list=False),
775
+ "obligated": FieldSchema(name="obligated", type=str, is_optional=True, is_list=False),
776
+ }
777
+
761
778
  OFFICERS_SCHEMA: dict[str, FieldSchema] = {
762
779
  "highly_compensated_officer_1_amount": FieldSchema(
763
780
  name="highly_compensated_officer_1_amount", type=Decimal, is_optional=True, is_list=False
@@ -1161,6 +1178,7 @@ GENERATED_NESTED: dict[str, dict[str, FieldSchema]] = {
1161
1178
  "NoticeHistory": NOTICE_HISTORY_SCHEMA,
1162
1179
  "NoticeHistory2": NOTICE_HISTORY2_SCHEMA,
1163
1180
  "NoticeType": NOTICE_TYPE_SCHEMA,
1181
+ "ObligationsByFiscalYear": OBLIGATIONS_BY_FISCAL_YEAR_SCHEMA,
1164
1182
  "Officers": OFFICERS_SCHEMA,
1165
1183
  "Opportunity": OPPORTUNITY_SCHEMA,
1166
1184
  "Opportunity2": OPPORTUNITY2_SCHEMA,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tango-python
3
- Version: 1.17.0
3
+ Version: 1.18.1
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,11 +1,11 @@
1
- tango/__init__.py,sha256=hyJnoG92kgW1ylC060yUS0hjSTlNfG55AiwfmdnCPdA,2739
2
- tango/client.py,sha256=-T4k3sX1EgDF8Bya77lvwM8yqL72nPABYrd_tgtIF1g,244423
1
+ tango/__init__.py,sha256=VqhIYcfNI56Lx8iBaT3qGYKpjaHxLWPpTC-fIujYxQA,2739
2
+ tango/client.py,sha256=awauFCq-gd-dCBAvDPeEBBgxwhuc_2ZzIhK-I7ki0U8,245711
3
3
  tango/exceptions.py,sha256=oPiLCccBoWLK5SjHkzP-oI6mUD9twEeKSvEuLV5h01I,4224
4
- tango/models.py,sha256=2kyX6ogMWVNfsBbh1ah5hUgWFH1EQuArwUCHzrHRY4Y,72598
4
+ tango/models.py,sha256=D9e8_AAAwVi1C4nOqdhWz-8ARBLPRsLGi8TDjucOMEY,72897
5
5
  tango/shapes/__init__.py,sha256=7ea1WU74jp4znhNw-gXruag6m6eyPZtbVgbDFmFUWro,1072
6
- tango/shapes/explicit_schemas.py,sha256=RCsUOVKe89WYPORVSAPKWX6u3If1DdI_7a94VTAbzrI,84525
6
+ tango/shapes/explicit_schemas.py,sha256=fwjHiFLOMpFyNLNM4M6kdK603s-t8gxHYqcSeL3jz7g,85674
7
7
  tango/shapes/factory.py,sha256=uDPhnp6VVzrLBKodxteZy5AcU43juEv-qKVRWth51j0,31550
8
- tango/shapes/generated_overlay.py,sha256=7UwqTeqNW4NIuwsQlKVZgBlH2biEVBdEZ4z2IwiS1k4,141244
8
+ tango/shapes/generated_overlay.py,sha256=vMrv0V_ShmP1-WxEW2o6Bv3IpmPMDl9ABtFj9Mo9YRY,142045
9
9
  tango/shapes/generator.py,sha256=xzakpwTwqTMUr89I06hp54-FIYZziviWHk2Glscg-LM,22775
10
10
  tango/shapes/models.py,sha256=h3pIhOqrrdlN953Y6r0oney5HFbKPOD-frRndRWimJ0,3018
11
11
  tango/shapes/parser.py,sha256=AecNx5oT_hV_pf2AWZnsR8Y2aLmCtjfgS9-znA2Pesc,27429
@@ -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.17.0.dist-info/METADATA,sha256=rZoauk0_jIBk6yraVOv_-FgWVcsRPDCFG2USzRdHYEo,22824
20
- tango_python-1.17.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
21
- tango_python-1.17.0.dist-info/entry_points.txt,sha256=kGLUbglUjuaAqEFvOZ1QuSW0vWb6VeSpCIFKaOFkKoQ,50
22
- tango_python-1.17.0.dist-info/licenses/LICENSE,sha256=j2kYVHMwTkoGn3ZNScnrdIueG0k2XzB_LCPFoyBc2wk,1064
23
- tango_python-1.17.0.dist-info/RECORD,,
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,,