Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Conditional imports to support pydantic>2
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguidry committed Oct 4, 2023
1 parent d5f4064 commit 47eb029
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion prefect_gitlab/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from gitlab import Gitlab
from prefect.blocks.core import Block
from pydantic import Field, HttpUrl, SecretStr
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import Field, HttpUrl, SecretStr
else:
from pydantic import Field, HttpUrl, SecretStr


class GitLabCredentials(Block):
Expand Down
7 changes: 6 additions & 1 deletion prefect_gitlab/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
from prefect.filesystems import ReadableDeploymentStorage
from prefect.utilities.asyncutils import sync_compatible
from prefect.utilities.processutils import run_process
from pydantic import Field, HttpUrl, validator
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import Field, HttpUrl, validator
else:
from pydantic import Field, HttpUrl, validator

from prefect_gitlab.credentials import GitLabCredentials

Expand Down
7 changes: 6 additions & 1 deletion tests/test_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
import pytest
from prefect.exceptions import InvalidRepositoryURLError
from prefect.testing.utilities import AsyncMock
from pydantic import SecretStr
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import SecretStr
else:
from pydantic import SecretStr

import prefect_gitlab
from prefect_gitlab.credentials import GitLabCredentials
Expand Down

0 comments on commit 47eb029

Please sign in to comment.