Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adding v1 / v2 incompatibility warning for nested v1 model#10431

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sydney-runkle merged 4 commits intomainfromincompat-warning
Sep 18, 2024

Conversation

sydney-runkle
Copy link
Contributor

Contributing to#10314

frompydanticimportBaseModelfrompydantic.v1importBaseModelasBaseModelV1classV1Model(BaseModelV1):    ...classV2Model(BaseModel):inner:V1Model"""UserWarning: Nesting V1 models inside V2 models is not supported. Please upgrade V1Model to V2."""

@sydney-runklesydney-runkle changed the titleAdding v1 / v2 incompatibility warning for nested v1 model:Adding v1 / v2 incompatibility warning for nested v1 modelSep 17, 2024
@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelSep 17, 2024
@sydney-runklesydney-runkle added relnotes-feature and removed relnotes-fixUsed for bugfixes. labelsSep 17, 2024
@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedSep 17, 2024
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:8f9599f
Status: ✅  Deploy successful!
Preview URL:https://3c809738.pydantic-docs.pages.dev
Branch Preview URL:https://incompat-warning.pydantic-docs.pages.dev

View logs

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedSep 17, 2024
edited
Loading

CodSpeed Performance Report

Merging#10431 willnot alter performance

Comparingincompat-warning (8f9599f) withmain (59a3de7)

Summary

✅ 49 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedSep 17, 2024
edited
Loading

Coverage report

Click to see where and how coverage changed

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

This report was generated bypython-coverage-comment-action

Comment on lines 826 to 830
if issubclass(obj, BaseModelV1):
warn(
f'Nesting V1 models inside V2 models is not supported. Please upgrade `{obj.__name__}` to V2.',
UserWarning,
)
Copy link
Member

Choose a reason for hiding this comment

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

This will warn when doing the following:

frompydanticimportTypeAdapterfrompydantic.v1importBaseModelasBaseModelV1TypeAdapter(BaseModelV1)

So maybe there's a way to check for the current model stack before warning?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Hmm, we don't supportTypeAdapter with v1 models anyways... so maybe I should just make the warning more broad?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I've modified the warning accordingly

@sydney-runklesydney-runkleenabled auto-merge (squash)September 18, 2024 13:57
@sydney-runklesydney-runkle merged commitfbfcc60 intomainSep 18, 2024
59 checks passed
@sydney-runklesydney-runkle deleted the incompat-warning branchSeptember 18, 2024 14:08
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ViicosViicosViicos approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@sydney-runkle@Viicos

[8]ページ先頭

©2009-2025 Movatter.jp