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
Pydantic V1 doesn't support mypy V1.1.1 #5192
Comments
In #5190 I found that version 1.10.2 of pydantic works well with mypy 1.1.1 YMMV |
Minor code base fixes: - Fix documentation rendering for lists in API doc-strings. - Update end2end_test.py according to updated dev tools guidelines. Concerning mypy. Pydantic v1 and mypy are not being updated properly. The latest working version of mypy with Pydantic v1 is v1.0.1, hence, mypy should henceforth be fixed to this version. See pydantic/pydantic#5192 for more information.
I believe all reported issues with using mypy 1.1.1 with pydantic v1 have been resolved, and fixes are included in the 1.10.7 release today. However, we don't currently run tests in CI againt mypy 1.1.1, so I'm not totally sure this is the case. Please continue to report any issues you hit with mypy 1.1.1 (whether using pydantic v1 or v2), and I will try to address them as I can. Many of the issues tracked here were actually also issues with earlier versions of mypy and/or required fixes in v2 as well, so it's very helpful. Also: I don't think we should "close" this issue until we have tests against mypy 1.1.1+ running in CI. |
I'm running mypy 1.1.1 with pydantic 1.10.7 in ci, it still failed because of pydantic, I'll create a issue with details later. |
This code is still not working with mypy 1.1.1 and pydantic 1.10.7:
|
@markedwards I assume you meant to inherit from I think this is going to be impossible to resolve without using the pydantic mypy plugin due to the fact that mypy now respects the It does appear to be working correctly if you use the pydantic mypy plugin though. |
Okay, actually, it looks like there may be a good solution: you can do class Settings(BaseModel):
foo: str = Field(default=..., env='foo') this has the same runtime semantics but the |
@dmontagu yes, corrected the example. Actually, you're right it's working okay with the plugin, and with the modification you suggest. I had thought the plugin was enabled in my environment but it was not. Thanks. |
Use latest SINTEF/ci-cd callable workflows Avoid TYPE_CHECKING blocks for coverage. Minor code base fixes: - Fix documentation rendering for lists in API doc-strings. - Update end2end_test.py according to updated dev tools guidelines. Concerning mypy. Pydantic v1 and mypy are not being updated properly. The latest working version of mypy with Pydantic v1 is v1.0.1, hence, mypy should henceforth be fixed to this version. See pydantic/pydantic#5192 for more information. Create DLite entities for OPTIMADE Structures. Implement DLite parser for OPTIMADE. Implement support for DLite in the Resource strategy.
I'm going to close this now, though will still note that I won't be surprised if there are issues. In general, for new versions of mypy, our goal will be to support them in v2 and backport fixes as best we can, but make no promises that we will maintain the integration of pydantic v1 with future mypy versions. |
We are aware that Pydantic doesn't support V1.1.1 of mypy.
This is a tracking progress of fixes for this
Issues so far:
from_orm
method on user's classes #5187explicit_package_bases
set as true #5191AFAIK v1.0.1 is pretty well supported by pydantic v1.10.6, if you find a problem with v1.0.1 and pydantic, please report it here.
Please don't create more issues about mypy >v1.0.1, instead comment here if you think the above issues don't cover the problem
Fix timeline
We currently working very hard on pydantic V2 and the significant complexity of pydantic V2 AND the pydantic mypy plugin means that switching back and forth between the two has a significant overhead.
Realistically we won't work on fixing the above for around a month, we will of course try to review community fixes.
My recommendation is to pin
mypy==1.0.1
or earlier.Partially related, Pydantic V2 will probably support
mypy>=1.2
, and we'll likely add a optional dependency grouppydantic[mypy]
just to constrain mypy, see python/typeshed#9771 (comment).The text was updated successfully, but these errors were encountered: