Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Commit a1be81a

Browse files
authored
Merge pull request #36 from PrefectHQ/pydantic-v2-compatibility
Conditional imports to support operating with `pydantic>2` installed
2 parents a3e4819 + b5fce0e commit a1be81a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

prefect_twitter/credentials.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
"""Credential classes used to perform authenticated interactions with Twitter"""
22

33
from prefect.blocks.core import Block
4-
from pydantic import Field, SecretStr
4+
from pydantic import VERSION as PYDANTIC_VERSION
5+
6+
if PYDANTIC_VERSION.startswith("2."):
7+
from pydantic.v1 import Field, SecretStr
8+
else:
9+
from pydantic import Field, SecretStr
10+
511
from tweepy import API, OAuth1UserHandler
612

713

@@ -31,16 +37,16 @@ class TwitterCredentials(Block):
3137
_documentation_url = "https://prefecthq.github.io/prefect-twitter/credentials/#prefect_twitter.credentials.TwitterCredentials" # noqa
3238

3339
consumer_key: str = Field(
34-
default=..., description="Twitter App API key used for authentication."
40+
..., description="Twitter App API key used for authentication."
3541
)
3642
consumer_secret: SecretStr = Field(
37-
defualt=..., description="Twitter App API secret used for authentication."
43+
..., description="Twitter App API secret used for authentication."
3844
)
3945
access_token: str = Field(
40-
default=..., description="Oauth token used to access the Twitter API."
46+
..., description="Oauth token used to access the Twitter API."
4147
)
4248
access_token_secret: SecretStr = Field(
43-
default=..., description="Ouath secret used to access the Twitter API."
49+
..., description="Ouath secret used to access the Twitter API."
4450
)
4551

4652
def get_api(self) -> API:

0 commit comments

Comments
 (0)