Repository navigation
chore: require pylance 12 and drop dead compatibility code - #5301
Closed
jonasdedden wants to merge 1 commit into
Closed
jonasdedden wants to merge 1 commit into
jonasdedden wants to merge 1 commit into
Conversation
Bump the minimum pylance to 12.0.0 and resolve the typing workarounds its annotations make obsolete: unused `type: ignore`s in field_path, fragment and index, the redundant PQ codebook cast, and the `CompactionOptions` casts (the TypedDict is now `total=False`). `Index.fragment_ids` is now annotated as `Bitmap`, so build one explicitly. Remove compatibility shims for pylance versions below the minimum: the pylance 4.x namespace/storage-options-provider path, the 0.36 version checks, signature probing of `write_fragments` and `scanner`, fallbacks for `initial_storage_options`, `fragment_id`, `serialized_manifest` and the single-argument `merge_index_metadata`, and the `optimize` API guards. Drop the tests and skips that only exercised those paths, plus redundant asserts on `optimize_indices`' already-typed return value. Pylance 12 defaults to a file format that rejects legacy blob columns, so the legacy blob tests now pin `data_storage_version="2.1"`.
Contributor
Author
Contributor
Author
|
Converting to Draft for now until #5295 is merged. Probably will split the PR into smaller parts then anyways. |
jonasdedden
marked this pull request as draft
September 28, 2026 11:36
This was referenced Sep 29, 2026
Contributor
Author
|
Closed in favor of smaller and invidiually reviewable PRs: |
jiaoew1991
pushed a commit
that referenced
this pull request
Nov 9, 2026
## Summary Part 3/3 of splitting up #5301. pylance 12 declares `CompactionOptions` as `TypedDict(total=False)`. An empty dict and partial `CompactionOptions(...)` literals now type-check, so the cast in `compact_files` and the test-only `_compaction_options` cast helper are no longer needed. No behavior change. `pyproject.toml` and `uv.lock` are untouched. ## Testing - `uv run mypy` (strict), `ruff check`, `ruff format --check`: clean - `pytest tests/test_distributed_compaction.py`: 14 passed - Full suite with all three split PRs combined: 299 passed, 0 skipped (pylance 12.0.0, Python 3.12)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Raises the minimum pylance version to
12.0.0, then removes the typing workarounds and version-compatibility code that the new minimum makes unnecessary.This overlaps with #5295, which makes the same bump. This PR also includes that PR's typing fixes and the legacy-blob test fix, so whichever lands second will need a small rebase.
Typing cleanups enabled by pylance 12
type: ignores that pylance 12's annotations make unused:LanceSchema.field()infield_path.pymax_rows_per_groupand thewrite_fragmentsreturn type infragment.py; mypy now picks the correct overload becausereturn_transaction=Falseis passed explicitlycreate_index_uncommitted(index_type=...)inindex.pyFixedSizeListArraycast on thetrain_pq_modelresult.Index.fragment_idsis now annotated asBitmap, so we passBitmap(...)instead of aset.CompactionOptionsis nowTypedDict(total=False):compact_filespassescompaction_options or {}without a cast.CompactionOptions(...)instead of a cast helper.is not None/isinstance(..., LanceDataset)asserts onlr.optimize_indices, which is already typed-> lance.LanceDataset.Removed dead compatibility code
Every removed shim targeted an API that already exists in pylance 10.0.0b7, the previous minimum. I checked each one against an installed 10.0.0b7.
utils.py: the pylance 4.xnamespace/storage_options_providerpath, including_pylance_versionand_create_storage_options_provider.LanceNamespaceStorageOptionsProviderdoesn't exist in any supported release.get_write_fragments_kwargswas just an alias forget_namespace_kwargs, so it's gone too.fragment.py: signature probing ofwrite_fragmentsand the "installed pylance does not support ..." errors. The write options are now passed directly.prepare_fragment_write_optionskeeps its real validation:target_basesandtarget_all_basesare mutually exclusive, and it still warns whenallow_external_blob_outside_basesis combined withingest.index.py:pylance >= 0.36.0version checks, including_check_pylance_versionmerge_index_metadata_compat, whose one-argument fallback is never usedhasattr(dataset, "optimize")/optimize_indicesguardssearch.py: theindex_segmentssignature probing, plus theinitial_storage_optionsandfragment_idfallbacks.datasource.py: theinitial_storage_optionsandserialized_manifestfallbacks.tests/_utils.py, which only held the write-option probing helpers, and theskipifs that used them.optimize_indicestest.0.36/0.37version gates and the "not yet implemented" / packed-struct skip branches.DatasetBasePath/blob_array/blob_field._declare_table_with_fallbackindatasink.pystays. It covers namespace implementations that don't implementdeclare_table, not older pylance versions.Behavior change in pylance 12
Pylance 12's default file format rejects legacy
lance-encoding:blobcolumns, so the tests intests/test_blob.pynow pindata_storage_version="2.1".Testing
uv run mypy(strict): no issues in 33 source files.uv run ruff check/ruff format --check: clean.uv run pytest -n 8: 297 passed, 0 skipped, withpylance==12.0.0on Python 3.13.