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

Add invalid schema placeholder #1469

Merged
merged 7 commits into from
Oct 7, 2024
Merged

Add invalid schema placeholder #1469

merged 7 commits into from
Oct 7, 2024

Conversation

sydney-runkle
Copy link
Member

@sydney-runkle sydney-runkle commented Sep 30, 2024

Progress on pydantic/pydantic#10299

Sort of reminds me of #619, maybe we want to change this implementation to reflect some of those constraints?

Copy link

codspeed-hq bot commented Sep 30, 2024

CodSpeed Performance Report

Merging #1469 will not alter performance

Comparing invalid-schema (95626d6) with main (e3eff5c)

Summary

✅ 155 untouched benchmarks

python/pydantic_core/core_schema.py Outdated Show resolved Hide resolved
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.

What's the current error message if you try to create a SchemaValidator containing one of these? Should it be improved?

@sydney-runkle
Copy link
Member Author

What's the current error message if you try to create a SchemaValidator containing one of these? Should it be improved?

Good question. Definitely could be improved, though seems maybe ok for now?

Traceback (most recent call last):
  File "/Users/programming/pydantic_work/pydantic-core/test.py", line 3, in <module>
    sv = SchemaValidator(core_schema.invalid_schema())
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.SchemaError: Unknown schema type: "invalid"

@sydney-runkle
Copy link
Member Author

@davidhewitt, I can easily edit the error message in mod.rs. What would you prefer?

@davidhewitt
Copy link
Contributor

That placeholder seems reasonable. How about adding a BuildValidator implementation that's guaranteed to error (with something like "invalid schemas can never be instantiated")?

@sydney-runkle sydney-runkle enabled auto-merge (squash) October 7, 2024 15:29
@sydney-runkle sydney-runkle merged commit 0af18c4 into main Oct 7, 2024
27 of 28 checks passed
@sydney-runkle sydney-runkle deleted the invalid-schema branch October 7, 2024 15:30
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