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/09 02:24:57 UTC
[GitHub] [spark] dchvn commented on a change in pull request #34439: [SPARK-37095][PYTHON] Inline type hints for files in python/pyspark/broadcast.py
dchvn commented on a change in pull request #34439:
URL: https://github.com/apache/spark/pull/34439#discussion_r745239197
##########
File path: python/pyspark/broadcast.py
##########
@@ -177,28 +201,28 @@ def destroy(self, blocking=False):
self._jbroadcast.destroy(blocking)
os.unlink(self._path)
- def __reduce__(self):
+ def __reduce__(self) -> Tuple[Callable[[int], T], Tuple[int]]:
if self._jbroadcast is None:
raise RuntimeError("Broadcast can only be serialized in driver")
- self._pickle_registry.add(self)
- return _from_id, (self._jbroadcast.id(),)
+ cast(Any, self._pickle_registry).add(self)
+ return cast(Tuple[Callable[[int], T], Tuple[int]], (_from_id, (self._jbroadcast.id(),)))
Review comment:
I use `cast` to match with type hint of this functions
##########
File path: python/pyspark/broadcast.py
##########
@@ -177,28 +201,28 @@ def destroy(self, blocking=False):
self._jbroadcast.destroy(blocking)
os.unlink(self._path)
- def __reduce__(self):
+ def __reduce__(self) -> Tuple[Callable[[int], T], Tuple[int]]:
if self._jbroadcast is None:
raise RuntimeError("Broadcast can only be serialized in driver")
- self._pickle_registry.add(self)
- return _from_id, (self._jbroadcast.id(),)
+ cast(Any, self._pickle_registry).add(self)
+ return cast(Tuple[Callable[[int], T], Tuple[int]], (_from_id, (self._jbroadcast.id(),)))
class BroadcastPickleRegistry(threading.local):
""" Thread-local registry for broadcast variables that have been pickled
"""
- def __init__(self):
+ def __init__(self) -> None:
self.__dict__.setdefault("_registry", set())
- def __iter__(self):
+ def __iter__(self) -> Generator[Broadcast, None, None]:
Review comment:
That differs from `broadcast.pyi` because we receive a `Generator` with `yield`
--
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