zero323 commented on a change in pull request #34510:
URL: https://github.com/apache/spark/pull/34510#discussion_r746405189



##########
File path: python/pyspark/mllib/stat/test.py
##########
@@ -15,68 +15,72 @@
 # limitations under the License.
 #
 
+from typing import Generic, Tuple, TypeVar
+
 from pyspark.mllib.common import inherit_doc, JavaModelWrapper
 
 
 __all__ = ["ChiSqTestResult", "KolmogorovSmirnovTestResult"]
 
+DF = TypeVar("DF", int, float, Tuple[int, ...], Tuple[float, ...])
+
 
-class TestResult(JavaModelWrapper):
+class TestResult(JavaModelWrapper, Generic[DF]):
     """
     Base class for all test results.
     """
 
     @property
-    def pValue(self):
+    def pValue(self) -> float:
         """
         The probability of obtaining a test statistic result at least as
         extreme as the one that was actually observed, assuming that the
         null hypothesis is true.
         """
-        return self._java_model.pValue()
+        return self._java_model.pValue()  # type: ignore[attr-defined]

Review comment:
       Let's not ignore this. If, at the moment, this is not exposed by 
`JavaModelWrapper` is it better to add it to the current 
   
   
https://github.com/apache/spark/blob/16e26049afc8ba92b06bdc58c47b211ea87e0d2b/python/pyspark/mllib/common.pyi#L30-L33
   
   i.e.
   
   ```python
   class JavaModelWrapper:
       _java_model: JavaObject
       ...
   ```
   
   Also, general advice ‒ it might be a good idea to look at the dependency 
tree of modules, before picking next one to annotate. Cyclic dependencies 
between annotations are rare (and non-existent in code), so it should make 
remaining migration process smoother.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to