Skip to content
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

Add a test demonstrating why we don't reset the parent namespace in create_model #8376

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

dmontagu
Copy link
Contributor

Adds a test showing why the line of code removed in #8011 was there

@@ -133,6 133,7 @@ class BaseModel(metaclass=_model_construction.ModelMetaclass):
# pydantic._internal._generate_schema.GenerateSchema.model_schema to work for a plain BaseModel annotation
model_fields = {}
__pydantic_decorators__ = _decorators.DecoratorInfos()
__pydantic_parent_namespace__ = None
Copy link
Contributor Author

@dmontagu dmontagu Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this attribute could fail to be defined in some places where it was accessed. (In particular, this was causing the added test to fail.)

Explicitly setting it to None here fixed that.

Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 465e884
Status: ✅  Deploy successful!
Preview URL: https://b4b137cd.pydantic-docs2.pages.dev
Branch Preview URL: https://dmontagu-create-model-no-res.pydantic-docs2.pages.dev

View logs

@dmontagu dmontagu added the relnotes-ignore Omit this PR from the release notes. label Dec 15, 2023
Copy link

codspeed-hq bot commented Dec 15, 2023

CodSpeed Performance Report

Merging #8376 will not alter performance

Comparing dmontagu/create-model-no-reset-parent-namespace (465e884) with main (3f6724b)

Summary

✅ 10 untouched benchmarks

Copy link
Member

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@dmontagu dmontagu merged commit 59c6172 into main Dec 15, 2023
55 of 56 checks passed
@dmontagu dmontagu deleted the dmontagu/create-model-no-reset-parent-namespace branch December 15, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-ignore Omit this PR from the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants