-
Notifications
You must be signed in to change notification settings - Fork 252
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 CoreSchemaType Literal #389
Conversation
) | ||
assert s.to_python(123, mode='json', exclude={1: {2}}) == ( | ||
"123 info=SerializationInfo(include=None, exclude={1: {2}}, mode='json', by_alias=True, exclude_unset=False, " | ||
"exclude_defaults=False, exclude_none=False, round_trip=False)" | ||
'exclude_defaults=False, exclude_none=False, round_trip=False)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to change this to make make
pass, here and elsewhere that quotes changed in test files
CodSpeed Performance ReportMerging #389 Summary
|
I know we talked about making all CoreSchema members inherit from a common type as a way to improve mypy performance. I'm happy to try that, though would have two questions:
|
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #389 +/- ##
=======================================
Coverage 95.31% 95.31%
=======================================
Files 90 90
Lines 10510 10511 +1
Branches 8 8
=======================================
+ Hits 10018 10019 +1
Misses 492 492
Continue to review full report at Codecov.
|
Here is what I did for #387:
from pydantic import BaseModel
I did some initial testing in #387. The issue I encountered was that If you just want to check if the typing would work, you could also try running Anyway, feel free to reuse any of the work I did #387 if that's of any help to you. |
@cdce8p thank you very much for sharing, this looks like it will be helpful, at least if I end up reaching the same conclusions as you I won't have to spend as much time as I would otherwise! |
(@samuelcolvin) So, @cdce8p, I checked out your branch for PR#387, and I got the following results following your testing description after pip-installing mypy:
This all seems to be working properly and very performantly using mypy. However, I do see the issue with PyRight not liking it:
For what it's worth, I found this stack overflow answer a bit enlightening on the issues: https://stackoverflow.com/a/71814659. It would be nice if pyright would have the same behavior as mypy here, but I'm assuming they don't on purpose; have we tried bringing this up with them at all? I had the idea that maybe we could introduce a couple aliases and try to trick the type systems so that mypy would see the aliases following #387, but pyright would see them the way it is currently on the main branch. However, I couldn't find a way to do type-checker-specific ignores (like |
Could you try running mypy over the |
@cdce8p Yep, that failed. (I had to get rid of the multiple I wouldn't be surprised if it was possible to do something with a mypy plugin here, but I'm not sure that's a good idea even if it is possible (big maintenance burden). @samuelcolvin I'm inclined to drop any attempt to address the mypy performance stuff as part of this PR, and just leave that open for discussion separately. |
I would still like to merge this PR adding the CoreSchemaType literal though if no objections from either of you. Happy to refactor in the future as appropriate if we find a better path for performance that somehow influences this. |
Agreed, any further changes can come later. Feel free to merge. |
No description provided.