bluesky / event-model

data model for event-based data collection and analysis
https://blueskyproject.io/event-model
BSD 3-Clause "New" or "Revised" License
15 stars 31 forks source link

Fixed imports to avoid pydantic if the version is >=2 #281

Closed evalott100 closed 1 year ago

evalott100 commented 1 year ago

Closes #280 Will now use dummy imports if the pydantic version is >= 2.0.0, not only if pydantic doesn't exist.

DominicOram commented 1 year ago

From the docs it looks like another option might be in v2 you can do from pydantic import v1 as pydantic, which might mean you can get it to work for both?

evalott100 commented 1 year ago

From the docs it looks like another option might be in v2 you can do from pydantic import v1 as pydantic, which might mean you can get it to work for both?

I've used try except with v1 now, so the generation code will work with either.

coretl commented 1 year ago

From the docs it looks like another option might be in v2 you can do from pydantic import v1 as pydantic, which might mean you can get it to work for both?

I've used try except with v1 now, so the generation code will work with either.

But the upper cap is still in to stop pydantic < 2 being installed?

evalott100 commented 1 year ago

From the docs it looks like another option might be in v2 you can do from pydantic import v1 as pydantic, which might mean you can get it to work for both?

I've used try except with v1 now, so the generation code will work with either.

But the upper cap is still in to stop pydantic < 2 being installed?

I think it's probably still good to pin pydantic<2 as a dev requirement since the generation code does require that version, the difference is that if event-model is installed as a requirement in an environment with pydantic 2 then the wrapper will use pydantic 1 instead.