Skip to content

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...

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', ()):

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-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
@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.

3 participants