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

tweaks to _core_utils #7040

Merged
merged 3 commits into from Aug 15, 2023
Merged

tweaks to _core_utils #7040

merged 3 commits into from Aug 15, 2023

Conversation

samuelcolvin
Copy link
Member

@samuelcolvin samuelcolvin commented Aug 8, 2023

Change Summary

some trivial cleanup to _core_utils::Walk.

Related issue number

related to #6768

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

Selected Reviewer: @hramezani

@samuelcolvin
Copy link
Member Author

please review.

Copy link
Contributor

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

I assume that we're trying to shave off as much constant overhead as we can here, overall LGTM with some suggestions and thoughts...

pydantic/_internal/_core_utils.py Show resolved Hide resolved
replaced_fields: dict[str, core_schema.ModelField] = {}
replaced_computed_fields: list[core_schema.ComputedField] = []
for computed_field in schema.get('computed_fields', None) or ():
for computed_field in schema.get('computed_fields') or ():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for computed_field in schema.get('computed_fields') or ():
for computed_field in schema.get('computed_fields', ()):

replaced_computed_fields: list[core_schema.ComputedField] = []
for computed_field in schema.get('computed_fields', None) or ():
for computed_field in schema.get('computed_fields') or ():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for computed_field in schema.get('computed_fields') or ():
for computed_field in schema.get('computed_fields', ()):

@@ -345,7 +348,7 @@ def handle_typed_dict_schema(self, schema: core_schema.TypedDictSchema, f: Walk)
def handle_dataclass_args_schema(self, schema: core_schema.DataclassArgsSchema, f: Walk) -> core_schema.CoreSchema:
replaced_fields: list[core_schema.DataclassField] = []
replaced_computed_fields: list[core_schema.ComputedField] = []
for computed_field in schema.get('computed_fields', None) or ():
for computed_field in schema.get('computed_fields') or ():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for computed_field in schema.get('computed_fields') or ():
for computed_field in schema.get('computed_fields', ()):

pydantic/_internal/_core_utils.py Show resolved Hide resolved
@cloudflare-pages
Copy link

cloudflare-pages bot commented Aug 15, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5525777
Status: ✅  Deploy successful!
Preview URL: https://7df1e640.pydantic-docs2.pages.dev
Branch Preview URL: https://tweak-fastapi-startup-test.pydantic-docs2.pages.dev

View logs

@samuelcolvin samuelcolvin enabled auto-merge (squash) August 15, 2023 09:06
@samuelcolvin samuelcolvin merged commit 2009d29 into main Aug 15, 2023
47 checks passed
@samuelcolvin samuelcolvin deleted the tweak-fastapi-startup-test branch August 15, 2023 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants