bzhaoopenstack commented on code in PR #37117:
URL: https://github.com/apache/spark/pull/37117#discussion_r919545172


##########
python/pyspark/ml/util.py:
##########
@@ -536,10 +536,8 @@ def __get_class(clazz: str) -> Type[RL]:
         """
         parts = clazz.split(".")
         module = ".".join(parts[:-1])
-        m = __import__(module)
-        for comp in parts[1:]:
-            m = getattr(m, comp)
-        return m
+        m = __import__(module, fromlist=[parts[-1]])
+        return getattr(m, parts[-1])

Review Comment:
   The original error from here is about type different error. As the previous 
function might return a python module type `m = __import__(module)`, then 
finally `return m` which can not be called, that's due to the [following line 
](https://github.com/apache/spark/blob/master/python/pyspark/ml/util.py#L546). 
And the defined return-value is a Type[RL], they are different. So I think this 
func should return a python Class at least. That's why I change 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-unsubscr...@spark.apache.org

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


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

Reply via email to