zero323 commented on a change in pull request #34411:
URL: https://github.com/apache/spark/pull/34411#discussion_r739003043
##########
File path: python/pyspark/conf.py
##########
@@ -133,28 +137,37 @@ def set(self, key, value):
self._conf[key] = str(value)
return self
- def setIfMissing(self, key, value):
+ def setIfMissing(self, key: str, value: str) -> "SparkConf":
"""Set a configuration property, if not already set."""
if self.get(key) is None:
self.set(key, value)
return self
- def setMaster(self, value):
+ def setMaster(self, value: str) -> "SparkConf":
"""Set master URL to connect to."""
self.set("spark.master", value)
return self
- def setAppName(self, value):
+ def setAppName(self, value: str) -> "SparkConf":
"""Set application name."""
self.set("spark.app.name", value)
return self
- def setSparkHome(self, value):
+ def setSparkHome(self, value: str) -> "SparkConf":
"""Set path where Spark is installed on worker nodes."""
self.set("spark.home", value)
return self
- def setExecutorEnv(self, key=None, value=None, pairs=None):
+ @overload
+ def setExecutorEnv(self, key: str, value: str) -> "SparkConf":
+ ...
+
+ @overload
+ def setExecutorEnv(self, *, pairs: List[Tuple[str, str]]) -> "SparkConf":
+ ...
+
+ # TODO
+ def setExecutorEnv(self, key=None, value=None, pairs=None): # type:
ignore[no-untyped-def]
Review comment:
> why do I need to use string formatting? Is it only for better
formatting?
You don't have to, but I'd expect that `key: Optional[str]` will raise
`[operator]` on `+`. In contrast, formatting doesn't care, and we already check
if `key is not None` in the conditional (however, only assertions `assert foo
is not None` are used to support checking).
--
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]