zero323 commented on a change in pull request #34411:
URL: https://github.com/apache/spark/pull/34411#discussion_r738758715
##########
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:
To address that.
- Add `type: ignore[arg-type]` (and possibly `operator`).
- Use`cast(str, _)`
- Add an assertions (`assert _ is nor None`)
For `key` alone, you could also switch to string formatting
(`f"spark.executorEnv.{key}"` / `"spark.executorEnv.{}".format(key)`)****
--
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]