lidavidm commented on code in PR #13109:
URL: https://github.com/apache/arrow/pull/13109#discussion_r906005079
##########
python/pyarrow/_compute.pyx:
##########
@@ -2198,7 +2198,20 @@ cdef class Expression(_Weakrefable):
-------
cast : Expression
"""
- options = CastOptions.safe(ensure_type(type))
+ safe_vars_passed = (safe is not None) or (type is not None)
+
+ if safe_vars_passed and (options is not None):
+ raise ValueError("Must either pass values for 'type' and 'safe' or
pass a "
+ "value for 'options'")
+
+ if options is None:
+ if type is None:
+ raise ValueError(
Review Comment:
Also, we can just call `ensure_type(type, allow_none=False)`. That has the
added benefit that it'll take string type arguments like `"int8"` like it did
before. (Though I guess maybe CastOptions does that same conversion.)
##########
python/pyarrow/_compute.pyx:
##########
@@ -2198,7 +2198,20 @@ cdef class Expression(_Weakrefable):
-------
cast : Expression
"""
- options = CastOptions.safe(ensure_type(type))
+ safe_vars_passed = (safe is not None) or (type is not None)
+
+ if safe_vars_passed and (options is not None):
+ raise ValueError("Must either pass values for 'type' and 'safe' or
pass a "
+ "value for 'options'")
+
+ if options is None:
+ if type is None:
+ raise ValueError(
Review Comment:
nit, but usually Python uses TypeError for things like missing arguments
(here and above)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]