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
feat: Add is_fixed discriminator to pricing types (#56)
* feat: Add is_fixed discriminator to pricing types
Synced updated AdCP schemas from upstream that add the is_fixed
discriminator field to pricing option types. This discriminator
distinguishes between fixed-rate and auction-based pricing options.
Changes:
- Synced 8 updated pricing schema files from upstream
- Regenerated all Python types from schemas
- Added is_fixed discriminator to pricing option types:
- CpcPricingOption (is_fixed=True)
- CpcvPricingOption (is_fixed=True)
- CpmFixedRatePricingOption (is_fixed=True)
- CpmAuctionPricingOption (is_fixed=False)
- CppPricingOption (is_fixed varies)
- CpvPricingOption (is_fixed varies)
- VcpmFixedRatePricingOption (is_fixed=True)
- VcpmAuctionPricingOption (is_fixed=False)
- FlatRatePricingOption (is_fixed=True)
The pricing types already have semantic names, so no new type
aliases were needed.
All 258 tests pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: Add development workflow and uv usage to CLAUDE.md
Added comprehensive documentation for:
- Using uv for package management (uv sync, uv run)
- Schema update workflow (sync → generate → test → review)
- When to use venv vs system python for different scripts
- Pricing type discriminators (is_fixed field)
This captures learnings from the pricing discriminator update
to help future development work go more smoothly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Pricing option types (`CpcPricingOption`, `CpmAuctionPricingOption`, `CpmFixedRatePricingOption`, etc.) already have clear semantic names from the schema generator, so they don't need aliases. These types now include an `is_fixed` discriminator:
This enables `uvx toolname` and `pip install toolname` to work correctly.
200
206
207
+
## Development Environment & Tools
208
+
209
+
**Using uv for Package Management**
210
+
211
+
This project uses `uv` for fast, reliable Python package management. ALWAYS use `uv` commands rather than bare `python` or `pip`:
212
+
213
+
```bash
214
+
# Install dependencies (including dev dependencies)
215
+
uv sync --extra dev
216
+
217
+
# Run scripts with the virtual environment
218
+
uv run pytest # Run tests
219
+
uv run python scripts/sync_schemas.py # Sync schemas
220
+
uv run python scripts/generate_types.py # Generate types
221
+
222
+
# Activate the virtual environment (if needed for multiple commands)
223
+
source .venv/bin/activate
224
+
# OR use .venv/bin/python directly
225
+
.venv/bin/python scripts/generate_types.py
226
+
```
227
+
228
+
**Schema Update Workflow**
229
+
230
+
When pulling in updated schemas from upstream:
231
+
232
+
1.**Sync schemas**: `python3 scripts/sync_schemas.py` (no venv needed, uses stdlib)
233
+
- Downloads latest schemas from AdCP GitHub
234
+
- Uses content hashing to only update changed schemas
235
+
- Updates `schemas/cache/.hashes.json` for tracking
236
+
237
+
2.**Generate types**: `uv run python scripts/generate_types.py` (requires dev dependencies)
238
+
- Requires `datamodel-code-generator` from dev dependencies
239
+
- Regenerates all Pydantic models from schemas
240
+
- Runs post-generation fixes automatically
241
+
- Consolidates exports into `generated.py`
242
+
243
+
3.**Verify changes**: `uv run pytest`
244
+
- All 258+ tests should pass
245
+
- Verifies backward compatibility
246
+
247
+
4.**Review for semantic aliases**: Check if new discriminated unions need aliases
248
+
- Look for numbered types (Type1, Type2) in generated files
249
+
- Add semantic aliases to `src/adcp/types/aliases.py` if needed
250
+
- Update exports in `src/adcp/__init__.py`
251
+
- Add tests in `tests/test_type_aliases.py`
252
+
253
+
**Important**: The sync_schemas.py script uses only Python stdlib (urllib, json, pathlib) and doesn't require the virtual environment. The generate_types.py script requires dev dependencies and must use `uv run` or the venv python.
0 commit comments