Skip to content

Commit c074bea

Browse files
committed
Fix typing issues
1 parent dc98046 commit c074bea

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

singlestoredb/functions/ext/rowdat_1.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,10 @@ def _load_numpy_accel(
578578
# then fill it in with the transformed values. The transformer may have
579579
# an output_type attribute that we can use to create a more specific type.
580580
if getattr(transformer, 'output_type', None):
581-
new_col = np.empty(len(numpy_cols[i][0]), dtype=transformer.output_type)
581+
new_col = np.empty(
582+
len(numpy_cols[i][0]),
583+
dtype=transformer.output_type, # type: ignore
584+
)
582585
new_col[:] = list(map(transformer, numpy_cols[i][0]))
583586
else:
584587
new_col = np.array(list(map(transformer, numpy_cols[i][0])))

singlestoredb/functions/typing/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,17 @@ def __new__(cls, *args: Unpack[Ts]) -> 'Table[Tuple[Unpack[Ts]]]': # type: igno
5353
return tuple.__new__(cls, args) # type: ignore
5454

5555

56-
class Transformer(Protocol):
56+
class TypedTransformer(Protocol):
5757

5858
output_type: Optional[Any] = None
5959

6060
def __call__(self, *args: Any, **kwargs: Any) -> Any:
6161
...
6262

6363

64+
Transformer = Union[Callable[..., Any], TypedTransformer]
65+
66+
6467
def output_type(dtype: Any) -> Callable[..., Any]:
6568
"""
6669
Decorator that sets the output_type attribute on a function.

singlestoredb/functions/typing/numpy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from numpy import array # noqa: F401
88

99
try:
10-
from typing import TypeAlias
10+
from typing import TypeAlias # type: ignore
1111
except ImportError:
12-
from typing_extensions import TypeAlias
12+
from typing_extensions import TypeAlias # type: ignore
1313

1414
from . import UDFAttrs
1515
from . import json_or_null_dumps

singlestoredb/functions/typing/pandas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from pandas import Series # noqa: F401
99

1010
try:
11-
from typing import TypeAlias
11+
from typing import TypeAlias # type: ignore
1212
except ImportError:
13-
from typing_extensions import TypeAlias
13+
from typing_extensions import TypeAlias # type: ignore
1414

1515
from . import UDFAttrs
1616
from . import json_or_null_dumps

singlestoredb/functions/typing/polars.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from polars import Series # noqa: F401
88

99
try:
10-
from typing import TypeAlias
10+
from typing import TypeAlias # type: ignore
1111
except ImportError:
12-
from typing_extensions import TypeAlias
12+
from typing_extensions import TypeAlias # type: ignore
1313

1414
from . import UDFAttrs
1515
from . import json_or_null_dumps

singlestoredb/functions/typing/pyarrow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from pyarrow import Table # noqa: F401
99

1010
try:
11-
from typing import TypeAlias
11+
from typing import TypeAlias # type: ignore
1212
except ImportError:
13-
from typing_extensions import TypeAlias
13+
from typing_extensions import TypeAlias # type: ignore
1414

1515
from . import UDFAttrs
1616
from . import json_or_null_dumps

0 commit comments

Comments
 (0)