You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ru...@apache.org on 2026/04/01 03:44:39 UTC
(spark) branch master updated: [SPARK-56271][PYTHON] Fix type hint and remove unused method for _globals.py
This is an automated email from the ASF dual-hosted git repository.
ruifengz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 1dd26f921849 [SPARK-56271][PYTHON] Fix type hint and remove unused method for _globals.py
1dd26f921849 is described below
commit 1dd26f9218491ff538b13f73ec39b0c7920009f7
Author: Tian Gao <ga...@hotmail.com>
AuthorDate: Wed Apr 1 11:44:19 2026 +0800
[SPARK-56271][PYTHON] Fix type hint and remove unused method for _globals.py
### What changes were proposed in this pull request?
* Add type hint for `_globals.py` and remove the ignore config in mypy
* Remove the `__reduce__` method that is only needed for python2
### Why are the changes needed?
Type hint is trivial and we can just do it. `__reduce__` is a legacy thing just for python2 which has been dead for years.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
mypy passed locally.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #55068 from gaogaotiantian/global-type-hint.
Authored-by: Tian Gao <ga...@hotmail.com>
Signed-off-by: Ruifeng Zheng <ru...@apache.org>
---
python/mypy.ini | 3 ---
python/pyspark/_globals.py | 8 ++------
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/python/mypy.ini b/python/mypy.ini
index aafba656ed27..04c27015ebaf 100644
--- a/python/mypy.ini
+++ b/python/mypy.ini
@@ -29,9 +29,6 @@ ignore_errors = True
; Allow untyped def in internal modules
-[mypy-pyspark._globals]
-disallow_untyped_defs = False
-
[mypy-pyspark.java_gateway]
disallow_untyped_defs = False
diff --git a/python/pyspark/_globals.py b/python/pyspark/_globals.py
index 81b4be145283..444d2881726f 100644
--- a/python/pyspark/_globals.py
+++ b/python/pyspark/_globals.py
@@ -54,17 +54,13 @@ class _NoValueType:
__instance = None
- def __new__(cls):
+ def __new__(cls) -> "_NoValueType":
# ensure that only one instance exists
if not cls.__instance:
cls.__instance = super().__new__(cls)
return cls.__instance
- # needed for python 2 to preserve identity through a pickle
- def __reduce__(self):
- return (self.__class__, ())
-
- def __repr__(self):
+ def __repr__(self) -> str:
return "<no value>"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org