vito-lin-dev opened a new pull request, #59377: URL: https://github.com/apache/spark/pull/59377
### What changes were proposed in this pull request? Remove five `type: ignore[union-attr]` comments in `pyspark.ml` by narrowing types or correcting annotations: - `ml/torch/torch_run_process_wrapper.py`: `task.stdin` / `task.stdout` are created with `subprocess.PIPE` and are never `None`; narrow with an `assert`. - `ml/connect/io_utils.py`: narrow `sparkContext._gateway` with an `assert`. - `ml/wrapper.py`: check `_gateway is not None` before calling `detach`, instead of relying on the surrounding `except`. - `ml/connect/tuning.py`: `param_map` comes from `Sequence[ParamMap]`, so annotate it as `ParamMap` instead of `Any`. - `ml/connect/base.py`: `Estimator.fit` only accepts a single `ParamMap` and never returns a list, but its return type was declared as `Union[M, List[M]]`. Correct it to `M`. This was the root cause of the ignore in `tuning.py`. ### Why are the changes needed? `type: ignore` hides real type errors. These five were covering either an un-narrowed `Optional` or an incorrect annotation. Replacing them lets mypy check the code, and fixes a misleading return type on `Estimator.fit`. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `dev/lint-python --mypy` passes. ### Was this patch authored or co-authored using generative AI tooling? Co-authored by Claude. Author reviewed every line, ran the tests, and verified the coverage results locally. -- 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]
