Skip to content

Commit

Permalink
feat: AirflowSerdeType
Browse files Browse the repository at this point in the history
  • Loading branch information
phi-friday committed Aug 15, 2024
1 parent a2a7b0e commit f9ecb7f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/airflow_serde_polars/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

if TYPE_CHECKING:
import polars as pl
from airflow.serialization.serde import U

from airflow_serde_polars.utils.typing import AirflowSerdeResponse

class Serializer(Protocol):
def __call__(self, o: object) -> AirflowSerdeResponse[U]: ... # pyright: ignore[reportUnknownParameterType]
def __call__(self, o: object) -> AirflowSerdeResponse: ...

class Deserializer(Protocol):
def __call__(
Expand Down
13 changes: 11 additions & 2 deletions src/airflow_serde_polars/utils/typing.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Tuple
from typing import TYPE_CHECKING, Any, Dict, List, Set, Tuple, Union

if TYPE_CHECKING:
from typing_extensions import TypeAlias, TypeVar

T = TypeVar("T", infer_variance=True)
T = TypeVar(
"T",
infer_variance=True,
bound="AirflowSerdeType[Any]",
default="AirflowSerdeType[Any]",
)
T2 = TypeVar("T2", infer_variance=True, bound="AirflowSerdeType", default=Any)

AirflowSerdeResponse: TypeAlias = Tuple[T, str, int, bool]
AirflowSerdeType: TypeAlias = Union[
bool, float, int, Dict[Any, T2], List[T2], str, Tuple[T2, ...], Set[T2]
]

ErrorResponse: AirflowSerdeResponse[Any] = ("", "", 0, False)

0 comments on commit f9ecb7f

Please sign in to comment.