leeeating opened a new pull request, #59355:
URL: https://github.com/apache/spark/pull/59355

   ### What changes were proposed in this pull request?
   
   This PR removes `# type: ignore[assignment]` comments that exist only 
because a variable is re-bound to a value of a different type:
   
   - `pyspark.ml.linalg.DenseMatrix.__repr__` and `SparseMatrix.__repr__`: 
`entries` / `values` / `rowIndices` / `colPtrs` were re-bound from lists to 
strings. The joined strings are now kept in new variables (`entries_str`, 
`values_str`, `row_indices_str`, `col_ptrs_str`).
   - `pyspark.mllib.linalg.SparseVector.parse`: `size` was re-bound from `str` 
to `int`. The string is now kept in `size_str`, which also removes the 
`cast(int, size)` at the end of the method.
   - `pyspark.ml.stat.KolmogorovSmirnovTest.test`: `params` was re-bound from a 
tuple to a list. The list is now kept in `float_params`.
   
   In total, 6 `type: ignore` comments and 1 `cast` are removed.
   
   `Vectors.dense` is left as is because removing its `type: ignore` requires 
changing the varargs handling.
   
   ### Why are the changes needed?
   
   To reduce unnecessary `type: ignore` comments so that mypy checks these 
lines instead of skipping them. The code structure is unchanged; only the 
re-bound variables are renamed.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. The `repr`/`str` output, the return value of `SparseVector.parse` and 
its error messages, and the values passed to the JVM are unchanged.
   
   ### How was this patch tested?
   
   - `./dev/lint-python` passed.
   - Doctests of `pyspark.ml.linalg` and `pyspark.mllib.linalg` passed.
   - Compared the `repr`/`str` output of `DenseMatrix` / `SparseMatrix` (empty, 
truncated, transposed, etc.) and the result/error messages of 
`SparseVector.parse` (valid and invalid inputs) before and after this change; 
they are identical.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code 2.1.296 (Claude Opus 5.5)
   
   The code and the PR text were drafted with the tool; the author chose the 
scope and the approach (keeping intermediate variables under new snake_case 
names instead of inlining).
   


-- 
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]

Reply via email to