HyukjinKwon opened a new pull request, #818:
URL: https://github.com/apache/spark-connect-rust/pull/818

   ### What changes were proposed in this pull request?
   
   Follow-ups of #777 (SPARK-61854), one commit each:
   
   #### 1. Run pyright in the offline test of the type stubs, as it runs mypy, 
and install it in the coverage job
   
   Stacked on `stubs-f3-native-modules`: this PR is its last commit, to merge 
after it.
   
   The type stubs are for mypy and pyright, and the docs say that both see 
PySpark's API as with `pyspark-client`, but CI ran only mypy. 
`python/tests/test_type_stubs_offline.py` runs pyright too, on the files that 
it runs mypy on:
   
   - `test_pyright_sees_the_user_application_as_with_the_official_client`: only 
the deliberate error of `type_stubs_user_app.py`, with the types that pyright 
reveals with `pyspark-client` 4.3.0;
   - `test_pyright_types_every_function_and_name_and_instance_attribute`: the 
562 functions of `pyspark.sql.functions.__all__`, none `Unknown`, every public 
name of the stubbed modules, and their public instance attributes, none 
`Unknown`, ten with the types of the official client.
   
   pyright is the executable of `$PYRIGHT` or `pyright`; without it the two 
tests skip with the reason. `coverage.yml` sets up Node.js 20 and installs 
`[email protected]` with npm, pinned as mypy is.
   
   #### 2. Describe what type checkers see of the drop-in, with the differences 
from pyspark-client that remain
   
   Stacked on `stubs-f6-pyright-ci`: this PR is its last commit, to merge after 
it.
   
   `docs/compatibility.md` said that mypy and pyright type an application as 
with `pyspark-client` but for three classes, which was not so: the stubs missed 
the attributes that PySpark's classes assign in their methods, declared names 
that the drop-in does not have, and did not cover `spark.dataSource` and 
`pyspark.ml.stat`. With the follow-ups before, the text describes what holds:
   
   - `docs/compatibility.md`: the modules that have stubs, with the instance 
attributes of their classes, checked with mypy and pyright; and the differences 
that remain, each with an example: the imports of PySpark's modules that the 
drop-in's modules do not have (errors, as at run time), the names that only 
PySpark's annotations need (`DataFrame.rdd`, the bases, metaclass and 
decorators of the native classes), the classes that the drop-in implements in 
another way (`SparkSession.client`, now with PySpark Connect's API, 
`SQLContext`, the internals of PySpark Connect), and the names that only the 
drop-in has (`Trigger`, `FrameBound`).
   - `docs/contributing.md`: a module that becomes PySpark's own, vendored as 
it is, leaves `STUB_MODULES`, and an extra name that the drop-in's module loses 
leaves `EXTRAS`, as `pyspark.sql.conf` and its `RuntimeConf` did.
   - `dev/parity/known-differences.md`: a section of the differences of type 
checking, with whether each is intentional.
   
   ### Why are the changes needed?
   
   **1.** So that a change that breaks the stubs for pyright, such as the 
`Optional` of `StructType.fields` that pyright gives a kept method body, which 
it does not narrow, fails CI as one for mypy does.
   
   **2.** So that a user and a contributor know what type checkers see of the 
drop-in, and what differs from `pyspark-client`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   **1.** No.
   
   **2.** No, documentation only.
   
   ### How was this patch tested?
   
   **1.** The two tests with pyright 1.1.414 on Node.js 24, and the suite 
without pyright, where they skip. `dev/design/ci.md` and `docs/contributing.md` 
describe the step.
   - The gates of the branch: `gen_type_stubs.py --check` and 
`gen_fn_dispatch.py --check`, `scripts/tests`, `test_type_stubs_offline.py`, 
ruff 0.14.0 `check` and `format --check`, `test_ruff_excludes.py`, 
`audit_no_stubs.sh` and the three guard steps of SPARK-61851 pass; the offline 
suite of `coverage.yml` passes 6167 tests, and its 2 failures 
(`test_session_hooks_see_deep_plans_as_pyspark[300]`, 
`test_every_native_class_has_its_bare_name_as_its_c_name`) fail the same way on 
master with the same local build of the extension.
   
   **2.** Each statement checked with mypy 2.4.1 and pyright 1.1.414 against 
`pyspark-client` 4.3.0 and this branch: seven applications, `spark.client`'s 46 
members, `SQLContext`, `spark.dataSource` and `pyspark.ml.stat`.
   - The gates of the branch: `gen_type_stubs.py --check` and 
`gen_fn_dispatch.py --check`, `scripts/tests`, `test_type_stubs_offline.py`, 
ruff 0.14.0 `check` and `format --check`, `test_ruff_excludes.py`, 
`audit_no_stubs.sh` and the three guard steps of SPARK-61851 pass; the offline 
suite of `coverage.yml` passes 6167 tests, and its 2 failures 
(`test_session_hooks_see_deep_plans_as_pyspark[300]`, 
`test_every_native_class_has_its_bare_name_as_its_c_name`) fail the same way on 
master with the same local build of the extension.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   
   This pull request and its description were written by Isaac.
   


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