This is an automated email from the ASF dual-hosted git repository.
gaogaotiantian pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-4.x by this push:
new bf3ec9600e23 [SPARK-60162][PYTHON] Correct DataFrame debugging
configuration type narrowing
bf3ec9600e23 is described below
commit bf3ec9600e2328e6ef7a857f4294ee2c8d753de6
Author: Matthew M.M <[email protected]>
AuthorDate: Mon Nov 9 14:54:05 2026 -0800
[SPARK-60162][PYTHON] Correct DataFrame debugging configuration type
narrowing
…narrowing
### What changes were proposed in this pull request?
This PR removes the `union-attr` type suppression from the DataFrame
debugging configuration lookup.
It stores the result of `RuntimeConfig.get` in a local variable and asserts
that the result is not `None` before calling `lower()`.
### Why are the changes needed?
`RuntimeConfig.get` is annotated to return `Optional[str]`. Therefore, mypy
treats the result as `str | None` and reports a `union-attr` error when
`lower()` is called directly.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
No new tests were added because this is a type-narrowing change with no
runtime behavior change.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #59365 from Horse-MA00/fix-dataframe-debugging-config-type.
Authored-by: Matthew M.M <[email protected]>
Signed-off-by: Tian Gao <[email protected]>
(cherry picked from commit 29816da715e29d3fd1efd1eafccd89242c662094)
Signed-off-by: Tian Gao <[email protected]>
skip-checks: true
---
python/pyspark/errors/utils.py | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/python/pyspark/errors/utils.py b/python/pyspark/errors/utils.py
index 115d9f31cb3b..7c1002142095 100644
--- a/python/pyspark/errors/utils.py
+++ b/python/pyspark/errors/utils.py
@@ -57,13 +57,9 @@ def is_debugging_enabled() -> bool:
spark = SparkSession.getActiveSession()
if spark is not None:
- _enable_debugging_cache = (
- spark.conf.get(
- "spark.python.sql.dataFrameDebugging.enabled",
- "true", # type: ignore[union-attr]
- ).lower()
- == "true"
- )
+ debugging_value =
spark.conf.get("spark.python.sql.dataFrameDebugging.enabled", "true")
+ assert debugging_value is not None
+ _enable_debugging_cache = debugging_value.lower() == "true"
else:
_enable_debugging_cache = False
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]