You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SPARK-55076][PYTHON] Fix the type hint issue in ml/mllib and add scipy requirement
### What changes were proposed in this pull request?
* Pin scipy version to >=1.8.0, which is the first minor version to support 3.10
* Install scipy on lint image so we can find scipy related lint failures
* Add `sparray` as that's the preferred type for scipy now
* Expand `VectorLike` to include other vector like types to simplify our code
* Replace some `type(x)` check with `isinstance()` because that's the recommended way and mypy understands it
* Fix a few `numpy` 1 vs 2 related type hints so they can pass with both versions
* Add a few assertions to make mypy happy about attributes
### Why are the changes needed?
Currently, local `mypy` check will fail with a lot of failures due to scipy/numpy because our lint image does not include those stubs. This is bad because it's really hard for people to do mypy check locally - they'll think that their environment setup has issues so `mypy` result is not to be trusted. We want to make `mypy` result consistent between CI and local and make it clean.
### Does this PR introduce _any_ user-facing change?
It should not. Almost all changes are type annotation related.
### How was this patch tested?
CI should pass.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes#53841 from gaogaotiantian/fix-ml-typehint.
Authored-by: Tian Gao <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
0 commit comments