You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -471,7 +473,12 @@ Contributions are welcome! Please feel free to submit a Pull Request.
471
473
472
474
1. Fork the repository
473
475
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
474
-
3. Run tests (`uv run pytest`)
475
-
4. Commit your changes (`git commit -m 'Add amazing feature'`)
476
-
5. Push to the branch (`git push origin feature/amazing-feature`)
477
-
6. Open a Pull Request
476
+
3. Run lint and format: `uv run ruff format tango/ && uv run ruff check tango/`
477
+
4. Run type checking: `uv run mypy tango/`
478
+
5. Run tests: `uv run pytest`
479
+
6. (Optional) Run [filter and shape conformance](scripts/README.md#filter-and-shape-conformance) if you have the tango API manifest; CI will run it on push/PR
480
+
7. Commit your changes (`git commit -m 'Add amazing feature'`)
481
+
8. Push to the branch (`git push origin feature/amazing-feature`)
482
+
9. Open a Pull Request
483
+
484
+
For a single command that runs formatting, linting, type checking, and tests (and conformance when the manifest is present), use: `uv run python scripts/pr_review.py --mode full`
The SDK provides predefined shape strings as constants on `ShapeConfig`. Use them as the `shape` argument for list/get methods when you want a consistent, validated set of fields without building a custom shape string.
911
+
912
+
```python
913
+
from tango import TangoClient, ShapeConfig
914
+
915
+
client = TangoClient()
916
+
917
+
# List methods default to the minimal shape when shape is omitted
All predefined shapes are validated at SDK release time (see [Developer Guide](DEVELOPERS.md#sdk-conformance-maintainers)). For custom shapes, see the [Shaping Guide](SHAPES.md).
947
+
948
+
---
949
+
907
950
## Error Handling
908
951
909
952
The SDK provides specific exception types for different error scenarios.
@@ -1094,7 +1137,8 @@ client = TangoClient()
1094
1137
1095
1138
## Additional Resources
1096
1139
1097
-
-[Shaping Guide](SHAPES.md) - Comprehensive guide to response shaping
1140
+
-[Shaping Guide](SHAPES.md) - Response shaping syntax, examples, and field reference
3. See [examples/](../examples/) for working code samples
624
625
4. Contact support at [tango@makegov.com](mailto:tango@makegov.com)
625
626
627
+
## SDK conformance (maintainers)
628
+
629
+
The SDK is kept in sync with the Tango API and its own shape schemas via two conformance checks. Both run in CI on every push and PR (see [Lint workflow](../.github/workflows/lint.yml)) and can be run locally with [scripts/check_filter_shape_conformance.py](../scripts/check_filter_shape_conformance.py).
630
+
631
+
### Filter conformance
632
+
633
+
-**What it checks:** Every list/get endpoint in the canonical manifest (from the [tango](https://github.com/makegov/tango) API repo) has a matching SDK method that exposes the manifest’s filter parameters—either as explicit arguments or via the method’s `api_param_mapping`.
634
+
-**Why it matters:** Ensures the SDK supports all query filters the API exposes for each resource, so users can filter without relying on undocumented `**kwargs`.
635
+
-**Warnings:** Methods that take filters only via `**kwargs` are reported as warnings (filter names cannot be verified against the manifest).
636
+
637
+
### Shape conformance
638
+
639
+
-**What it checks:** Every predefined shape in `ShapeConfig` (e.g. `CONTRACTS_MINIMAL`, `IDVS_MINIMAL`, `GRANTS_MINIMAL`) is parsed and validated against the SDK’s explicit schemas in `tango/shapes/explicit_schemas.py`. Each shape must only reference fields that exist for that model (including nested fields).
640
+
-**Why it matters:** Ensures default shapes never reference invalid or renamed fields, so default list/get behavior stays valid after schema or API changes.
641
+
-**Errors:** Parse failures or invalid field names in any `ShapeConfig` constant are reported as errors and fail the check.
642
+
643
+
### Running the conformance check
644
+
645
+
-**In CI:** The [Lint workflow](../.github/workflows/lint.yml) runs the full check automatically (it has access to the manifest). No setup needed for push/PR.
646
+
-**Locally:** You need the manifest file to run the script. If you have it (e.g. a path to `filter_shape_contract.json` from the [tango](https://github.com/makegov/tango) repo—wherever you keep that repo—or from a colleague), run:
647
+
```bash
648
+
uv run python scripts/check_filter_shape_conformance.py --manifest /path/to/filter_shape_contract.json
649
+
```
650
+
If you don’t have the manifest, CI will still run the full check on your branch; shape conformance is included whenever the script runs.
651
+
-**Output:** JSON with `errors` and `warnings`. Exit code 1 if there are any errors. See [scripts/README.md](../scripts/README.md#filter-and-shape-conformance) for full usage and `--list-missing`.
652
+
626
653
## Next Steps
627
654
628
655
- Read the [API Reference](API_REFERENCE.md) for detailed class and method documentation
Copy file name to clipboardExpand all lines: docs/SHAPES.md
+30-2Lines changed: 30 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
Response shaping lets you control which fields the API returns, making your requests faster and more efficient. Instead of receiving hundreds of fields you don't need, you specify exactly what you want.
4
4
5
+
**See also:**[API Reference](API_REFERENCE.md) for method parameters and [ShapeConfig (predefined shapes)](API_REFERENCE.md#shapeconfig-predefined-shapes); [Developer Guide](DEVELOPERS.md) for dynamic models and maintainer conformance.
Instead of writing shape strings by hand, you can use the SDK’s predefined constants. Each list/get method has a default minimal shape when you omit `shape`; you can also pass a constant explicitly.
44
+
45
+
```python
46
+
from tango import TangoClient, ShapeConfig
47
+
48
+
client = TangoClient()
49
+
50
+
# These are equivalent (list_contracts defaults to CONTRACTS_MINIMAL)
**Available constants:** Contracts (`CONTRACTS_MINIMAL`), Entities (`ENTITIES_MINIMAL`, `ENTITIES_COMPREHENSIVE`), Forecasts, Opportunities, Notices, Grants, IDVs, Vehicles, Organizations, OTAs, OTIDVs, Subawards. See [API Reference – ShapeConfig](API_REFERENCE.md#shapeconfig-predefined-shapes) for the full table and which method uses which constant.
Copy file name to clipboardExpand all lines: scripts/README.md
+27-3Lines changed: 27 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,8 @@ This directory contains utility scripts used during development and maintenance
12
12
### Testing and Validation
13
13
14
14
-**`test_production.py`** - Runs production API smoke tests against the live API
15
-
-**`pr_review.py`** - Runs configurable validation checks for PR review (linting, type checking, tests)
15
+
-**`pr_review.py`** - Runs configurable validation checks for PR review (linting, type checking, tests, conformance)
16
+
-**`check_filter_shape_conformance.py`** - Validates SDK filter and shape conformance (see [Filter and shape conformance](#filter-and-shape-conformance))
16
17
17
18
## Usage
18
19
@@ -56,8 +57,10 @@ uv run python scripts/pr_review.py --mode production --changed-files-only
56
57
**Validation Modes:**
57
58
-`smoke` - Production API smoke tests only
58
59
-`quick` - Linting + type checking (no tests)
59
-
-`full` - All checks (linting + type checking + all tests)
60
-
-`production` - Production API smoke tests + linting + type checking (default)
60
+
-`full` - All checks (linting + type checking + filter/shape conformance + all tests)
61
+
-`production` - Linting + type checking + filter/shape conformance + production API smoke tests (default)
62
+
63
+
When the conformance manifest is present (`tango-api/contracts/filter_shape_contract.json` or `TANGO_CONTRACT_MANIFEST`), both `full` and `production` run the [filter and shape conformance](#filter-and-shape-conformance) check. If the manifest is missing, that step is skipped with a warning.
61
64
62
65
**PR Detection:**
63
66
The script automatically detects PR information from:
@@ -70,6 +73,27 @@ When a PR is detected, the script displays PR information and automatically:
70
73
- Checks only changed files
71
74
- Shows PR URL in summary
72
75
76
+
### Filter and shape conformance
77
+
78
+
The SDK is validated against a canonical manifest (from the [tango](https://github.com/makegov/tango) API repo) for **filter conformance** and against its own schemas for **shape conformance**:
79
+
80
+
1.**Filter conformance** – Ensures every list/get method exposes the filter parameters defined in the manifest (e.g. `award_date`, `naics_code`, `agency`). Methods that use `**kwargs` for filters are reported as warnings because their filter names cannot be verified.
81
+
2.**Shape conformance** – Ensures every `ShapeConfig` constant (e.g. `CONTRACTS_MINIMAL`, `IDVS_MINIMAL`) parses correctly and only references fields that exist in the SDK’s explicit schemas for that model. Invalid or unknown fields in default shapes are reported as errors.
82
+
83
+
This script runs in CI on every push/PR (see [Lint workflow](.github/workflows/lint.yml)). The manifest file is produced by the tango API repo and must be available for the full check.
84
+
85
+
```bash
86
+
# Full check (filter + shape). Requires manifest from tango API repo.
87
+
uv run python scripts/check_filter_shape_conformance.py --manifest tango-api/contracts/filter_shape_contract.json
88
+
89
+
# List resources that have no matching SDK method (for implementation checklist)
90
+
uv run python scripts/check_filter_shape_conformance.py --manifest tango-api/contracts/filter_shape_contract.json --list-missing
91
+
```
92
+
93
+
**Output:** JSON with `manifest`, `errors`, and `warnings`. Exit code 1 if there are any errors (missing filters, invalid shapes, or missing SDK methods for manifest resources).
94
+
95
+
**Local runs:** To run the full check locally, you need a copy of `filter_shape_contract.json` (from the [tango](https://github.com/makegov/tango) repo’s `contracts/` directory—wherever you keep that repo). Pass it with `--manifest` or set `TANGO_CONTRACT_MANIFEST`. The script runs both filter and shape conformance; shape conformance validates all `ShapeConfig` defaults against `tango/shapes/explicit_schemas.py`.
96
+
73
97
## Requirements
74
98
75
99
-`TANGO_API_KEY` environment variable (required for production API tests)
0 commit comments