Fix example generator wrapping named number types in non-existent constructors#3440
Merged
Merged
Conversation
…structors
Named OpenAPI schemas with `type: number` (e.g. RumRetentionFilterSampleRate)
don't generate Python classes, but the example generator was emitting broken
constructor calls like `RumRetentionFilterSampleRate(50.0)` and a matching
import for a module that doesn't exist.
Root cause: the primitive-type exclusion set on formatter.py:280 was missing
"number", causing any named number schema with a $ref to be treated as a class.
Fix: add "number" to the exclusion set, matching the existing PRIMITIVE_TYPES
constant. Enum-typed number schemas are unaffected (the `or schema.get("enum")`
branch still fires). Also regenerates the two broken RUM retention filter
examples.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
jack-edmonds-dd
approved these changes
Apr 23, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 24, 2026
…structors (#3440) Named OpenAPI schemas with `type: number` (e.g. RumRetentionFilterSampleRate) don't generate Python classes, but the example generator was emitting broken constructor calls like `RumRetentionFilterSampleRate(50.0)` and a matching import for a module that doesn't exist. Root cause: the primitive-type exclusion set on formatter.py:280 was missing "number", causing any named number schema with a $ref to be treated as a class. Fix: add "number" to the exclusion set, matching the existing PRIMITIVE_TYPES constant. Enum-typed number schemas are unaffected (the `or schema.get("enum")` branch still fires). Also regenerates the two broken RUM retention filter examples. Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> a3384aa
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
type: number(e.g.RumRetentionFilterSampleRate) don't generate Python classes, but the example generator was emitting broken code: a constructor call and import for a module that doesn't existformatter.py:280excluded{"string", "integer", "boolean"}from constructor wrapping but was missing"number", so any namedtype: numberschema with a$refwas treated as a class type"number"to the exclusion set — consistent with the existingPRIMITIVE_TYPESconstant. Theor schema.get("enum")guard is preserved, so enum-typed number schemas remain unaffectedCreateRetentionFilter.py,UpdateRetentionFilter.py)Affected examples (broken → fixed)
Test plan
cd .generator && poetry run pytest tests/test_formatter.py -v— all 17 tests passpoetry run pytest tests/test_scenarios.py— all 3432 scenarios passfind examples/ -name "*.py" | xargs python3 -m py_compile— all examples compile cleanly🤖 Generated with Claude Code