Repository navigation
Fix crash in type_with_config for parametrized generics when pydantic is installed - #1194
Open
sophiecarreras wants to merge 2 commits into
Open
sophiecarreras wants to merge 2 commits into
sophiecarreras wants to merge 2 commits into
Conversation
… is installed `list[X]` is a `types.GenericAlias` and cannot take a `__pydantic_config__` attribute, so every JSON option typed `list[...]` (e.g. `--lifecycle-rules`) raised AttributeError when pydantic is installed. The type is now used unchanged in that case. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
|
Code review (independent pass). Important (fixed in the follow-up commit)
Nit (not changed)
|
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.
list[X]is atypes.GenericAliasand cannot take a__pydantic_config__attribute, so every JSON option typedlist[...](e.g.--lifecycle-rules) raisedAttributeError: 'types.GenericAlias' object has no attribute '__pydantic_config__'when pydantic (thefullextra) is installed.type_with_confignow catches theAttributeErrorand uses the type unchanged; pydantic applies its defaults in that case.No upstream issue exists for this; its text is below instead.
Reproduce on v5.0.2 / master 9ea898a (Python 3.12, pydantic 2.12.5):
Fails:
test_create_bucket__with_lifecycle_rules,test_create_bucket__mutually_exclusive_lifecycle_rules_options. The defaultnox -s unitdoes not install thefullextra, so CI does not see it.Verification (Python 3.12, pydantic 2.12.5):
test/unit/_cli/test_obj_loads.pyfail; after it all pass.test/unitgives the same results as before. 8 autocomplete/shell-install tests fail identically with and without the change in my environment.ruff checkandruff format --checkpass. The new pydantic-specific test is skipped when pydantic is not installed, like the existing one next to it.Includes changelog fragment
changelog.d/+pydantic-generic-alias.fixed.md.🤖 Generated with Claude Code