-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support installation with Pydantic v2 #307
Comments
Did you use npe2 without napari? As much more work need to be done on napari side to support npe2. |
We use Napari 0.4.17, which pulls npe2>=0.5.2 as dependency. When testing Pydantic 2, we got an import error directly from npe2, although considering how much Napari uses Pydantic it probably also needs porting. Interestingly, importing Napari does not immediately raise the error (but later). I found that we were directly importing |
Napari itself has a lazy import mechanism, so |
@Czaki well, we can do the strategy suggested by @aeisenbarth, right? Replace every instance of from pydantic import Foo with try:
from pydantic.v1 import Foo
except ModuleNotFoundError:
from pydantic import Foo Where does this fall down? |
I could have a try on doing a pull request for napari and npe2, if this is the decided way to do it. |
it should not fail if app-model is already ported: |
I also want to point to @tlambert03's pydantic-compat which looks a little bit like what https://github.com/tlambert03/pydantic-compat But using |
This was closed by #321 |
Description
Pydantic 2 is a rewrite with certain attractive features that developers (may) want to use, but are on hold because
npe2
only supportspydantic<2
.from pydantic.v1 import BaseModel
. So without changing much of the code, one can add switches that importpydantic
if version 1, otherwisepydantic.v1
(if version 2).The text was updated successfully, but these errors were encountered: