Skip to content

Conversation

@airwoodix
Copy link
Contributor

@airwoodix airwoodix commented May 27, 2024

Change Summary

This patch includes documentation for BaseModel.model_validate_strings() introduced in #7552 to the docs build.

Background on the validate_strings() feature is discussed in #7549 and #8736 in particular. Is a more detailed explanation necessary, especially to show the differences between the three validation helpers on BaseModel?

The pydantic-core stubs have _StringInput = dict[str, _StringInput] as type annotation for the object to validate. Since the pydantic implementation fully delegates to pydantic-core, only dicts are actually allowed. Should the annotation in pydantic be updated?

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

@github-actions github-actions bot added documentation relnotes-fix Used for bugfixes. labels May 27, 2024
@airwoodix airwoodix marked this pull request as draft May 27, 2024 13:20
@codspeed-hq
Copy link

codspeed-hq bot commented May 27, 2024

CodSpeed Performance Report

Merging #9506 will not alter performance

Comparing airwoodix:docs-basemodel-validate-strings (7c259b6) with main (afa1738)

Summary

✅ 13 untouched benchmarks

@airwoodix airwoodix force-pushed the docs-basemodel-validate-strings branch from 4bba640 to cebfebc Compare May 27, 2024 13:43
@airwoodix airwoodix marked this pull request as ready for review May 27, 2024 13:57
@airwoodix
Copy link
Contributor Author

please review

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.

This patch includes documentation for BaseModel.model_validate_strings() introduced in #7552 to the docs build.

Amazing, thanks! Great work here.

Background on the validate_strings() feature is discussed in #7549 and #8736 in particular. Is a more detailed explanation necessary, especially to show the differences between the three validation helpers on BaseModel?

I don't think we need something much more in depth, though perhaps we could pull a bit of info from:

https://github.com/pydantic/pydantic-core/blob/fd262933683fad0a9706e63298065f0d6ab9905d/python/pydantic_core/_pydantic_core.pyi#L170-L184

The pydantic-core stubs have _StringInput = dict[str, _StringInput] as type annotation for the object to validate. Since the pydantic implementation fully delegates to pydantic-core, only dicts are actually allowed. Should the annotation in pydantic be updated?

What are you suggesting we update the annotation to? Feel free to make the change, and I can review in context!

Ping me when you'd like another review :).

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

Hi @airwoodix,

Let me know if you have any other questions about the above notes!

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.

I've made a few minor wording changes - looks good otherwise!

@sydney-runkle sydney-runkle enabled auto-merge (squash) June 7, 2024 15:18
@sydney-runkle sydney-runkle merged commit 4dfde6f into pydantic:main Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author revision awaiting changes from the PR author documentation relnotes-fix Used for bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants