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/11/02 10:51:18 UTC

[GitHub] [spark] zero323 edited a comment on pull request #34466: [SPARK-37152][PYTHON] Inline type hints for python/pyspark/context.py

zero323 edited a comment on pull request #34466:
URL: https://github.com/apache/spark/pull/34466#issuecomment-957327097


   >  1. I used lots of "cast" to cancel the error, but is there other better way?
   
   I see that these are primarily related to union attributes. We have ongoing discussion about this, so it is not a binding opinion, but if it is repeated usage within the same block you can try asserting at the beginning:
   
   ```python
   assert self._jvm is not None
   ...
   self._jvm.PythonUtils.getPythonAuthSocketTimeout(self._jsc)
   ```
   
   or extract local variable with single ignore or cast
   
   ```python
   jvm = cast(JVMView, self._jvm)
   
   jvm.PythonUtils.getPythonAuthSocketTimeout(self._jsc)
   ```
   
   In a long run, we might consider adding some helpers to handle such case. Maybe something like this? 
   
   ```python
       @property
       def _jvm(self) -> JVMView:
           jvm = SparkContext._jvm
           assert jvm is not None
           return jvm
   ```
   
   It is definitely not in the scope of this PR though.


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