zero323 commented on a change in pull request #35252:
URL: https://github.com/apache/spark/pull/35252#discussion_r794464904
##########
File path: python/pyspark/conf.py
##########
@@ -203,6 +203,18 @@ def setAll(self, pairs: List[Tuple[str, str]]) ->
"SparkConf":
self.set(k, v)
return self
+ @overload
+ def get(self, key: str) -> Optional[str]:
+ ...
+
+ @overload
+ def get(self, key: str, defaultValue: None) -> Optional[str]:
+ ...
+
+ @overload
+ def get(self, key: str, defaultValue: str) -> str:
+ ...
+
Review comment:
It covers both, but doesn't capture the same relationship between
arguments. With `(SparkConf, str, str) -> str` we know that
```python
conf.get("foo", "42")
```
is `str`, which saves as cast / ignores / asserts not None later.
With only `(SparkConf, str, Optional[str]) -> Optional[str]` we still have
to assert that result is not `None`.
(There might be other way of capturing this through type parameters, i.e.
`(SparkConf, str, T) -> T` where `T` is `TypeVar("T", None, str)`)
--
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]