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 4ac9a775723c [SPARK-60176][ML] Replace remote identifier type ignores
with assertions
4ac9a775723c is described below
commit 4ac9a775723cc79ec80f2c85cb453d6e799e1a04
Author: Tim Hsiung <[email protected]>
AuthorDate: Thu Nov 5 12:29:58 2026 -0800
[SPARK-60176][ML] Replace remote identifier type ignores with assertions
### What changes were proposed in this pull request?
Replace two `type: ignore` comments in remote ML calls with string
assertions before parsing object identifiers.
### Why are the changes needed?
Make the existing string requirement explicit and let mypy narrow the type
without suppressing errors.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
- Mypy passed for all 114 ML source files.
- Existing ML typing suite: 11 tests passed.
- Ruff lint/format and `git diff --check` passed.
No new tests: this is a small type-narrowing cleanup. JVM/server
integration tests were not run.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: pi 1.1.0
Closes #59378 from bearomorphism/fix/ml-java-object-typing.
Authored-by: Tim Hsiung <[email protected]>
Signed-off-by: Tian Gao <[email protected]>
(cherry picked from commit 2284fb31af0a22d6123cfc1415ae97df084dc50f)
Signed-off-by: Tian Gao <[email protected]>
---
python/pyspark/ml/util.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/python/pyspark/ml/util.py b/python/pyspark/ml/util.py
index 447cf44c3c4c..402e506457b3 100644
--- a/python/pyspark/ml/util.py
+++ b/python/pyspark/ml/util.py
@@ -108,7 +108,8 @@ def invoke_remote_attribute_relation(
object_id = instance._java_obj.ref_id
else:
# model summary
- object_id = instance._java_obj # type: ignore
+ assert isinstance(instance._java_obj, str)
+ object_id = instance._java_obj
methods, obj_ref = _extract_id_methods(object_id)
methods.append(pb2.Fetch.Method(method=method,
args=serialize(session.client, *args)))
@@ -299,7 +300,8 @@ def try_remote_call(f: FuncT) -> FuncT:
obj_id = self._java_obj.ref_id
else:
# model summary
- obj_id = self._java_obj # type: ignore
+ assert isinstance(self._java_obj, str)
+ obj_id = self._java_obj
methods, obj_ref = _extract_id_methods(obj_id)
methods.append(pb2.Fetch.Method(method=name,
args=serialize(session.client, *args)))
command = pb2.Command()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]