Skip to content

Commit 0d69ac4

Browse files
authored
chore: cleanup type errors in bigframes/operations/__init__.py (#742)
1 parent efb3f21 commit 0d69ac4

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

bigframes/operations/__init__.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ def _convert_expr_input(
161161
def create_unary_op(name: str, type_signature: op_typing.UnaryTypeSignature) -> UnaryOp:
162162
return dataclasses.make_dataclass(
163163
name,
164-
[("name", typing.ClassVar[str], name), ("output_type", typing.ClassVar[typing.Callable], type_signature.as_method)], # type: ignore
164+
[
165+
("name", typing.ClassVar[str], name),
166+
("output_type", typing.ClassVar[typing.Callable], type_signature.as_method),
167+
],
165168
bases=(UnaryOp,),
166169
frozen=True,
167170
)()
@@ -172,7 +175,10 @@ def create_binary_op(
172175
) -> BinaryOp:
173176
return dataclasses.make_dataclass(
174177
name,
175-
[("name", typing.ClassVar[str], name), ("output_type", typing.ClassVar[typing.Callable], type_signature.as_method)], # type: ignore
178+
[
179+
("name", typing.ClassVar[str], name),
180+
("output_type", typing.ClassVar[typing.Callable], type_signature.as_method),
181+
],
176182
bases=(BinaryOp,),
177183
frozen=True,
178184
)()
@@ -493,8 +499,9 @@ def output_type(self, *input_types):
493499
if self.to_type == pa.string():
494500
return dtypes.STRING_DTYPE
495501
if isinstance(self.to_type, str):
496-
# TODO(b/340895446): fix type error
497-
return dtypes.BIGFRAMES_STRING_TO_BIGFRAMES[self.to_type] # type: ignore
502+
return dtypes.BIGFRAMES_STRING_TO_BIGFRAMES[
503+
typing.cast(dtypes.DtypeString, self.to_type)
504+
]
498505
return self.to_type
499506

500507

@@ -516,8 +523,10 @@ class RemoteFunctionOp(UnaryOp):
516523

517524
def output_type(self, *input_types):
518525
# This property should be set to a valid Dtype by the @remote_function decorator or read_gbq_function method
519-
# TODO(b/340895446): fix type error
520-
return self.func.output_dtype # type: ignore
526+
if hasattr(self.func, "output_dtype"):
527+
return self.func.output_dtype
528+
else:
529+
raise AttributeError("output_dtype not defined")
521530

522531

523532
@dataclasses.dataclass(frozen=True)
@@ -644,8 +653,10 @@ class BinaryRemoteFunctionOp(BinaryOp):
644653

645654
def output_type(self, *input_types):
646655
# This property should be set to a valid Dtype by the @remote_function decorator or read_gbq_function method
647-
# TODO(b/340895446): fix type error
648-
return self.func.output_dtype # type: ignore
656+
if hasattr(self.func, "output_dtype"):
657+
return self.func.output_dtype
658+
else:
659+
raise AttributeError("output_dtype not defined")
649660

650661

651662
add_op = AddOp()

0 commit comments

Comments
 (0)