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

Fix usage of PlainSerializer with builtin types #9450

Merged
merged 3 commits into from
May 20, 2024

Conversation

Viicos
Copy link
Contributor

@Viicos Viicos commented May 17, 2024

Change Summary

Related issue number

Fixes #9447

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: @alexmojaki

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label May 17, 2024
@@ -293,7 +293,7 @@ def get_function_type_hints(
except AttributeError:
type_hints = get_type_hints(function)
if isinstance(function, type):
type_hints.setdefault('return', type)
type_hints.setdefault('return', function)
Copy link
Contributor Author

@Viicos Viicos May 17, 2024

Choose a reason for hiding this comment

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

@sydney-runkle, I believe you meant to use the function (well in this case the type) here in your previous fix?

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks!

Copy link

codspeed-hq bot commented May 17, 2024

CodSpeed Performance Report

Merging #9450 will not alter performance

Comparing Viicos:issue/plain-serializers (01a7c5e) with main (7bdfac3)

Summary

✅ 13 untouched benchmarks

@Viicos Viicos marked this pull request as ready for review May 18, 2024 06:56
@Viicos
Copy link
Contributor Author

Viicos commented May 18, 2024

Please review

Copy link
Member

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

Wonderful, thanks!

@sydney-runkle sydney-runkle enabled auto-merge (squash) May 18, 2024 17:27
auto-merge was automatically disabled May 20, 2024 08:47

Head branch was pushed to by a user without write access

@sydney-runkle
Copy link
Member

@Viicos, looks like some tests are failing?

@Viicos
Copy link
Contributor Author

Viicos commented May 20, 2024

@sydney-runkle On PyPy, inspect.signature is able to get the signature of str:

<Signature (object=<no value>, encoding=<no value>, errors=<no value>)>

As the _serializer_info_arg function does not really take into account arguments with default values, it fails to determine if the info argument is required. I'll open a new issue with a clear example, in the meanwhile I disabled the test on PyPy so that this one can be merged.

@sydney-runkle sydney-runkle merged commit 9030415 into pydantic:main May 20, 2024
52 checks passed
@Viicos Viicos deleted the issue/plain-serializers branch May 20, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use str as argument to PlainSerializer
3 participants