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 2021/09/29 18:27:23 UTC

[GitHub] [spark] ueshin commented on a change in pull request #34130: [SPARK-36880][PYTHON] Inline type hints for python/pyspark/sql/functions.py

ueshin commented on a change in pull request #34130:
URL: https://github.com/apache/spark/pull/34130#discussion_r718758937



##########
File path: python/pyspark/sql/functions.py
##########
@@ -80,13 +96,13 @@ def _invoke_binary_math_function(name, col1, col2):
     )
 
 
-def _options_to_str(options=None):
+def _options_to_str(options: Optional[Any] = None) -> dict:

Review comment:
       ```py
   def _options_to_str(options: Optional[Dict[str, Any]] = None) -> Dict[str, str]:
   ```
   ?

##########
File path: python/pyspark/sql/functions.py
##########
@@ -4450,7 +4573,7 @@ def _unresolved_named_lambda_variable(*name_parts):
     )
 
 
-def _get_lambda_parameters(f):
+def _get_lambda_parameters(f: Callable) -> Any:

Review comment:
       Can the return type be more specific instead of `Any`?

##########
File path: python/pyspark/sql/functions.py
##########
@@ -1586,15 +1651,25 @@ def when(condition, value):
     >>> df.select(when(df.age == 2, df.age + 1).alias("age")).collect()
     [Row(age=3), Row(age=None)]
     """
-    sc = SparkContext._active_spark_context
+    sc = SparkContext._active_spark_context  # type: ignore[attr-defined]
     if not isinstance(condition, Column):
         raise TypeError("condition should be a Column")
     v = value._jc if isinstance(value, Column) else value
     jc = sc._jvm.functions.when(condition._jc, v)
     return Column(jc)
 
 
-def log(arg1, arg2=None):
+@overload   # type: ignore[no-redef]

Review comment:
       Do we need the `type: ignore[no-redef]` annotation here?
   What's the error like without it?




-- 
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