Skip to content
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

Add check for pydantic 1.x as first step for suporting for 2.x #295

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uplink/converters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# fmt: off
from uplink.converters.standard import StandardConverter
from uplink.converters.marshmallow_ import MarshmallowConverter
from uplink.converters.pydantic_ import PydanticConverter
from uplink.converters.pydantic_v1_ import PydanticConverter
from uplink.converters.typing_ import TypingConverter
# fmt: on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
from uplink.converters.interfaces import Factory, Converter
from uplink.utils import is_subclass

try:
from pydantic.version import VERSION
if not VERSION.startswith('1.'):
pydantic = None
else:
import pydantic

except ImportError: # pragma: no cover
pydantic = None


def _encode_pydantic(obj):
from pydantic.json import pydantic_encoder
Expand Down Expand Up @@ -72,11 +82,7 @@ def get_users(self, username) -> List[UserModel]:

$ pip install uplink[pydantic]
"""

try:
import pydantic
except ImportError: # pragma: no cover
pydantic = None
pydantic = pydantic

def __init__(self):
"""
Expand Down