Skip to content

Conversation

@dmontagu
Copy link
Collaborator

@dmontagu dmontagu commented Mar 29, 2023

This resolves the issue of some definitions refs not getting updated properly.

The issue in pydantic only required the fix for ModelValidator, but the comments where this stuff is used seemed to indicate that every contained validator should have complete called. So I went through all the files and made sure this was done (many were missing this).

I think it might be preferable if you had to explicitly define the fn complete for each Validator type and didn't get a default for free, but I don't know how hard that would be to refactor. (Yes there would be a bunch of trivial implementations but I feel that's less likely to cause errors than forgetting to "complete" a new validator type.)

Alternatively I guess it could make sense to refactor so this "completion" wasn't necessary, if that's even possible, but I also don't know how hard that would be.



def union_schema(union_type: UnionType) -> core_schema.UnionSchema | core_schema.RecursiveReferenceSchema:
def union_schema(union_type: UnionType) -> core_schema.UnionSchema | core_schema.DefinitionReferenceSchema:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I noticed a few out-of-date references to RecursiveReferenceSchema and fixed those up as well.

@dmontagu
Copy link
Collaborator Author

please review

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 29, 2023

CodSpeed Performance Report

Merging #494 fix-complete (066ec24) will not alter performances.

Summary

🔥 0 improvements
❌ 0 regressions
✅ 93 untouched benchmarks

🆕 0 new benchmarks
⁉️ 0 dropped benchmarks

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks for this.

Removing the need for complete() is hard, it might even be impossible, definitely not with the hassle now.

Making complete required is very simple and probably worthwhile, feel free to do it here or create an issue.

@dmontagu
Copy link
Collaborator Author

I will merge this as is now, but created an issue: #496

@dmontagu dmontagu merged commit 12f596d into main Mar 29, 2023
@dmontagu dmontagu deleted the fix-complete branch March 29, 2023 22:58
davidhewitt pushed a commit to pydantic/pydantic that referenced this pull request Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants