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

Relax protected namespace config default#10441

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 9 commits intomainfromprotected-ns
Oct 2, 2024
Merged

Conversation

sydney-runkle
Copy link
Contributor

@sydney-runklesydney-runkle commentedSep 18, 2024
edited
Loading

Closes#10315

Decided not to warn on method overrides, as that's an incredibly common practice in Python, and type checking does enough warning here in cases of incompatibility.

@sydney-runklesydney-runkle added the relnotes-changeUsed for changes to existing functionality which don't have a better categorization. labelSep 18, 2024
Copy link
Contributor

@hyperlint-aihyperlint-aibot left a comment

Choose a reason for hiding this comment

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

1 files reviewed, 1 outstanding issue(s) found.

@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

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

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:36a7816
Status: ✅  Deploy successful!
Preview URL:https://5749a93c.pydantic-docs.pages.dev
Branch Preview URL:https://protected-ns.pydantic-docs.pages.dev

View logs

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedSep 18, 2024
edited
Loading

CodSpeed Performance Report

Merging#10441 willnot alter performance

Comparingprotected-ns (36a7816) withmain (296f2ca)

Summary

✅ 38 untouched benchmarks

@sydney-runklesydney-runkleforce-pushed theprotected-ns branch 2 times, most recently from231eb93 toe9d3e43CompareSeptember 19, 2024 14:27
changing tests, adding updatesremove added spaceUpdate docs/concepts/serialization.mdCo-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>Update docs/concepts/serialization.mdCo-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>removing warning related code
removing unneeded warning check
@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedSep 19, 2024
edited
Loading

Coverage report

This PR does not seem to contain any modification to coverable code.

Copy link
Member

@samuelcolvinsamuelcolvin left a comment

Choose a reason for hiding this comment

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

one real question, otherwise LGTM.

Copy link
Contributor

@hyperlint-aihyperlint-aibot left a comment

Choose a reason for hiding this comment

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

1 files reviewed, 2 total issue(s) found.

@sydney-runkle
Copy link
ContributorAuthor

sydney-runkle commentedOct 2, 2024
edited
Loading

I think this should be ready for review. Given#10493, I actually don't think it's necessary that we addmodel_fields,model_extra, etc to theprotected_namespaces default:

frompydanticimportBaseModelfromtypingimportAnyclassUser(BaseModel):model_fields:list[str]model_computed_fields:list[str]model_extra:dict[str,Any]model_fields_set:set[str]user=User(model_fields=['id','name'],model_computed_fields=[],model_extra={},model_fields_set={'id','name'})"""/Users/programming/pydantic_work/pydantic/pydantic/_internal/_fields.py:190: UserWarning: Field name "model_fields" in "User" shadows an attribute in parent "BaseModel"  warnings.warn(/Users/programming/pydantic_work/pydantic/pydantic/_internal/_fields.py:190: UserWarning: Field name "model_computed_fields" in "User" shadows an attribute in parent "BaseModel"  warnings.warn(/Users/programming/pydantic_work/pydantic/pydantic/_internal/_fields.py:190: UserWarning: Field name "model_extra" in "User" shadows an attribute in parent "BaseModel"  warnings.warn(/Users/programming/pydantic_work/pydantic/pydantic/_internal/_fields.py:190: UserWarning: Field name "model_fields_set" in "User" shadows an attribute in parent "BaseModel"  warnings.warn("""

I've also enabled support for compiled patterns, though I don't think that's necessary, as all other overrides are methods - which are standard practice to override, and you'll get type checking warnings if signature isn't compatible or b) warnings if something conflicts with the protected namespaces.

@@ -273,7 +273,7 @@ def push(self, config_wrapper: ConfigWrapper | ConfigDict | None):
ser_json_inf_nan='null',
validate_default=False,
validate_return=False,
protected_namespaces=('model_',),
protected_namespaces=('model_validate', 'model_dump'),
Copy link
Member

Choose a reason for hiding this comment

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

Do we also want to addmodel_construct here?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Good question, cc@samuelcolvin@dmontagu

Copy link
ContributorAuthor

@sydney-runklesydney-runkleOct 2, 2024
edited
Loading

Choose a reason for hiding this comment

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

Following up here - we decided we didn't need to addmodel_construct - that's not a namespace we anticipate expanding in the same way we do formodel_dump_ etc, you can imaginepython,json,some_other_format.

@sydney-runklesydney-runkle merged commiteb9b838 intomainOct 2, 2024
61 checks passed
@sydney-runklesydney-runkle deleted the protected-ns branchOctober 2, 2024 18:18
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@samuelcolvinsamuelcolvinsamuelcolvin left review comments

@elidlockeelidlockeelidlocke left review comments

@hyperlint-aihyperlint-ai[bot]hyperlint-ai[bot] left review comments

@ViicosViicosViicos approved these changes

Assignees
No one assigned
Labels
relnotes-changeUsed for changes to existing functionality which don't have a better categorization.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Relax defaultprotected_namespaces config setting (removemodel_)
4 participants
@sydney-runkle@samuelcolvin@elidlocke@Viicos

[8]ページ先頭

©2009-2025 Movatter.jp