-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix false positives on v1 models in mypy plugin for from_orm check requiring from_attributes=True config #9938
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 false positives on v1 models in mypy plugin for from_orm check requiring from_attributes=True config #9938
Conversation
CodSpeed Performance ReportMerging #9938 will not alter performanceComparing Summary
|
tests/mypy/outputs/1.0.1/pyproject-plugin_toml/from_orm_v1_noconflict.py
Outdated
Show resolved
Hide resolved
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.
This looks good to me, other than — can we try removing the duplicates of the from_orm_v1_noconflict.py
file so we only keep the one in the 1.0.1
folder? I think that will still pass CI since it seems there are no changes in the subsequent versions.
Unfortunately it seems that it may be difficult to resolve the issue with deprecated, as I think mypy doesn't have a way for plugins to override the behavior of decorated methods. I might be misinterpreting something, but it seems that python/mypy#9915 might be necessary to achieve this (not sure). I think there are things we could do to avoid the decorator affecting the plugin behavior, but I would expect that to get in the way of some desirable errors produced by calling deprecated methods. So I'm not sure what's best here |
@dmontagu Thanks for the review, removed the duplicate result files. For the decorator I have no clue how to approach it without breaking the deprecation warning either. One way to "resolve" it would be to focus the unit of test on not raising "pydantic-orm" error for |
CI passes as expected, thanks. |
@dmontagu Please re-review. Is there a hope to get this fix included in a 2.8 patch release without waiting for 2.9 rollout? |
Please review |
Thanks for the ping. I messaged @dmontagu and we'll take a look shortly! |
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.
I think you shouldn’t need this file at all if there are no mypy errors produced
@sydney-runkle Are you able to provide any timeline for release containing that fix? |
Was planning on releasing this with v2.9 in late August! |
So I guess I shouldn't wait for |
Right, I don't think we're in a rush for a v2.8.3 at the moment, but I'll keep you updated! |
Change Summary
This is a fix for bug reported in #9936 when using both v1 and v2 for migration period with
pydantic.mypy
plugin enabled the"<ModelName>" does not have from_attributes=True [pydantic-orm]
error is getting raised forpydantic.v1.BaseModel
models that should not be checked bypydantic.mypy
plugin (that is supposed to work on current - v2 - pydantic).Please review but note that test will fail unless the other bug with
@typing_extensions.deprecated
decorator mentioned in #9936 is fixed.Open for discussion how to address the decorator messing with mypy hooks.
Related issue number
fix #9936
Checklist
Selected Reviewer: @sydney-runkle