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

Conditional imports to support operating with pydantic>2 installed #29

Merged
merged 1 commit into from
Oct 4, 2023
Merged
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
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