Step 5: dealer, VIN, usage models + validators + public exports#2
Merged
Conversation
Implements step 5 of the implementation plan: - src/visor/models/dealers.py: DealerFilter, DealerAddress, DealerSummary, DealerDetail, DealersPage - src/visor/models/vins.py: VinDetail (latest_listing uses ListingSnapshot) - src/visor/models/usage.py: UsageRecord, UsageTotals, UsageMeta, UsageSummary - src/visor/models/__init__.py: re-exports all public model types - src/visor/__init__.py: exports exceptions and all model types - tests/test_models.py: 22 response-parsing tests covering all new models Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- DealerFilter: enforce limit <= 100 and dealer_id list length <= 100 - FacetsFilter: enforce facet_value_limit <= 100; add model_validator requiring exactly one categorical facet when metric is set - src/visor/__init__.py: add missing public exports (DealerAddress, DealerRef, FacetBucket, FacetsData, UsageMeta, UsageRecord, UsageTotals) - tests/test_models.py: add 10 tests covering the new validators Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dealers.py,vins.py, andusage.pymodel files (step 5 of the implementation plan)models/__init__.pyandvisor/__init__.pywith all public model exportstests/test_models.pycovering response parsing and request validatorsWhat's in this PR
New files
src/visor/models/dealers.py—DealerFilter,DealerAddress,DealerSummary,DealerDetail,DealersPagesrc/visor/models/vins.py—VinDetail(latest_listingtyped asListingSnapshot)src/visor/models/usage.py—UsageRecord,UsageTotals,UsageMeta,UsageSummarytests/test_models.py— 50 response-parsing and validator testsUpdated files
src/visor/models/__init__.py— re-exports all public model typessrc/visor/__init__.py— exports exceptions + all model typessrc/visor/models/facets.py—facet_value_limitmax-100 validator;model_validatorrequiring exactly one categorical facet whenmetricis setsrc/visor/models/dealers.py—limitmax-100 validator;dealer_idlist length max-100 validatorValidator decisions
DealerFilterlimits — bothlimitanddealer_idare capped at 100 per the API docs, matching the existing pattern inListingsFilter.FacetsFilter.metric+ categorical facet — whenmetricis set, the model validator requires exactly one categorical facet (any facet that is notprice,msrp,miles, ordays_on_market). Those four are the range facets (they producerange_facetsin the response, not bucketedfacets). The rule rejects zero categorical facets (nothing to group by) and two or more (ambiguous grouping).Test plan
pytest— 50 tests, all passingruff check .— cleanruff format --check .— cleanmypy src/— clean🤖 Generated with Claude Code