You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/01/19 03:11:04 UTC

[GitHub] [spark] Yikun commented on a change in pull request #35236: [SPARK-37903][PYTHON][FOLLOW-UP] Raise TypeError with no return function

Yikun commented on a change in pull request #35236:
URL: https://github.com/apache/spark/pull/35236#discussion_r787315973



##########
File path: python/pyspark/pandas/typedef/typehints.py
##########
@@ -559,6 +559,9 @@ def infer_return_type(f: Callable) -> Union[SeriesType, DataFrameType, ScalarTyp
 
     tpe = get_type_hints(f).get("return", None)
 
+    if tpe is None:
+        raise TypeError("A return value is required for the input function")

Review comment:
       Technically, I think it should be ValueError, because func is `Callable` but the value is not not meet the requirement. See also in why raise TypeError before (it just because some compatiable reason):
   
   https://github.com/python/cpython/blob/7c0914d35eaaab2f323260ba5fe8884732533888/Lib/inspect.py#L1374-L1379
   
   It's not a strong prefer for me, just a reminder, you could do a double check on this, if you have other idea on this, I'm ok with this.




-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org