Skip to content

Remove guarding check on computed field with field_serializer #10390

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

Merged

Conversation

nix010
Copy link
Contributor

@nix010 nix010 commented Sep 12, 2024

Change Summary

Remove guarding check on computed field with field_serializer

Related issue number

#9683

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: @sydney-runkle

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Sep 12, 2024
@nix010
Copy link
Contributor Author

nix010 commented Sep 12, 2024

please review

Copy link

codspeed-hq bot commented Sep 12, 2024

CodSpeed Performance Report

Merging #10390 will not alter performance

Comparing nix010:9683-computed-field-and-field-serializer (4be672b) with main (a6dc872)

Summary

✅ 49 untouched benchmarks

Copy link
Contributor

github-actions bot commented Sep 12, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic/_internal
  _decorators.py
  _generate_schema.py
Project Total  

This report was generated by python-coverage-comment-action

def two_x(self) -> int:
return self.x * 2
@field_serializer('two_x')
def ser_two_x_bad_signature(self, v, _info):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably rename this - doesn't have a bad signature now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can probably delete this test honestly - not sure of the value here anymore, especially given the other test added above.

Copy link
Contributor

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

A few change requests, thanks!

def two_x(self) -> int:
return self.x * 2
@field_serializer('two_x')
def ser_two_x_bad_signature(self, v, _info):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can probably delete this test honestly - not sure of the value here anymore, especially given the other test added above.

@pydantic-hooky pydantic-hooky bot added awaiting author revision awaiting changes from the PR author and removed ready for review labels Sep 12, 2024
@pydantic-hooky pydantic-hooky bot assigned nix010 and unassigned sydney-runkle Sep 12, 2024
@sydney-runkle sydney-runkle added relnotes-feature and removed awaiting author revision awaiting changes from the PR author relnotes-fix Used for bugfixes. labels Sep 12, 2024
@sydney-runkle
Copy link
Contributor

LGTM overall - happy to merge after we fix up the tests a bit.

Confirming with the team that there was no reason not to support this, before we merge as well.

@sydney-runkle
Copy link
Contributor

sydney-runkle commented Sep 12, 2024

See #6965 where this was added - there's some other relevant code that we should update. We can remove the computed_field: bool from the _apply_field_serializers function, as well :).

@sydney-runkle sydney-runkle added the awaiting author revision awaiting changes from the PR author label Sep 12, 2024
@nix010
Copy link
Contributor Author

nix010 commented Sep 13, 2024

@sydney-runkle removed. please review again.

See #6965 where this was added - there's some other relevant code that we should update. We can remove the computed_field: bool from the _apply_field_serializers function, as well :).

@pydantic-hooky pydantic-hooky bot added ready for review and removed awaiting author revision awaiting changes from the PR author labels Sep 13, 2024
@pydantic-hooky pydantic-hooky bot assigned sydney-runkle and unassigned nix010 Sep 13, 2024
Copy link
Contributor

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

Great work! Thanks so much @nix010!

@sydney-runkle sydney-runkle merged commit 656481f into pydantic:main Sep 13, 2024
60 checks passed
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.

2 participants