Skip to content

Fix PydanticUserError on empty model_config with annotations #10412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

cdwilson
Copy link
Contributor

@cdwilson cdwilson commented Sep 15, 2024

Change Summary

Prevents a PydanticUserError from being raised when model_config has type annotations (model_config: ConfigDict), but is also empty.

For example, this previously raised a PydanticUserError:

class Model(BaseModel):
    model_config: ConfigDict = {}

Related issue number

Fixes #10411

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Prevents a `PydanticUserError` from being raised when `model_config` has
type annotations (`model_config: ConfigDict`), but is also empty.

For example, this previously raised a `PydanticUserError`:

class Model(BaseModel):
    model_config: ConfigDict = {}

Fixes pydantic#10411
@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Sep 15, 2024
Copy link

codspeed-hq bot commented Sep 15, 2024

CodSpeed Performance Report

Merging #10412 will not alter performance

Comparing tinydantic:cdwilson/fix-issue-10411 (ec1a501) with main (5d5b8af)

Summary

✅ 49 untouched benchmarks

Copy link
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic/_internal
  _config.py
Project Total  

This report was generated by python-coverage-comment-action

@Viicos
Copy link
Member

Viicos commented Sep 15, 2024

Thanks for the bug report and fix @cdwilson

@Viicos Viicos merged commit a764871 into pydantic:main Sep 15, 2024
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-fix Used for bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PydanticUserError raised when model_config has type annotation and is empty
2 participants