merge-api / merge-python-client

The Python SDK for accessing various Merge Unified APIs
Other
6 stars 11 forks source link

proof: support for both pydantic 1 & 2 #47

Closed Vivalldi closed 1 year ago

Vivalldi commented 1 year ago

Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

Opening based on the recommendation of the readme and understand this'll likely not be merged. Addresses #46

dsinghvi commented 1 year ago

@Vivalldi is there a way to do this such that the branching logic for importing pydantic doesn't have to be done in every file?

Vivalldi commented 1 year ago

@Vivalldi is there a way to do this such that the branching logic for importing pydantic doesn't have to be done in every file?

You could do the branching logic in one file and then reimport from all others.

src/merge/deps.py

try:
  import pydantic.v1 as pydantic
except ImportError:
  import pydantic

src/merge/somefile.py

from src.merge.deps import pydantic

Mobile so can't test but that should be the gist of it

Vivalldi commented 1 year ago

I've gone ahead and created a branch with these same changes in the fern project. Haven't opened a PR yet as I figured you all are already looking into this and I haven't had a chance to test the results yet.

dsinghvi commented 1 year ago

@Vivalldi you're crushing it 🔥

Vivalldi commented 1 year ago

Work in upstream has already started. Will let team generate