Skip to content

Fix lazy resolution of class and function object completions - #742

Open
Mohamed-El-Mouhib wants to merge 1 commit into
python-lsp:developfrom
Mohamed-El-Mouhib:fix/resolve-jedi-object-completions
Open

Mohamed-El-Mouhib wants to merge 1 commit into
python-lsp:developfrom
Mohamed-El-Mouhib:fix/resolve-jedi-object-completions

Conversation

@Mohamed-El-Mouhib

Copy link
Copy Markdown

Problem

When jedi_completion.include_class_objects or include_function_objects is enabled, the additional object completion items are returned to the client but cannot be resolved lazily. For example, with both settings enabled, Fooclass and Foofunc() resolve normally, while Fooclass object and Foofunc() object remain without documentation or detail after completionItem/resolve.

The cache construction zips the expanded list of LSP completion items with the original, shorter Jedi completion list. The appended items are consequently omitted from LAST_JEDI_COMPLETIONS.

Change

Keep a parallel list of source Jedi completions and append the corresponding source for each additional object item. Build the existing resolution cache from the paired lists. This preserves the completion ordering, insertion text, kind, and document URI metadata without changing eager resolution or the existing cache format.

Adds regression tests for class-only, function-only, and combined object completion settings, checking both ordinary and appended items, order, cache membership, document metadata, and the documentation of each resolved item.

Validation

  • All three new regression cases fail on unmodified upstream a362006 (missing appended cache entries) and pass on this branch.
  • Independently exercised the actual stdio JSON-RPC transport with the same class/function fixture on exact upstream and patched sources: the two ordinary items resolve on both revisions, but the two object items gain their correct detail and documentation only after the fix. Passed on CPython 3.14.7 and 3.15.2.
  • On macOS arm64, using CPython 3.14.7 and the project's [all,test] dependencies: CI=true OS=macos PYTHON_VERSION=3.14 python -m pytest --color=yes -v test/ — 204 passed, 10 skipped, 0 failures, 90% overall coverage. The skips are existing platform/CI-specific conditions.
  • Ruff 0.9.4 (the CI-pinned version): ruff check pylsp test and ruff format --check pylsp test passed.
  • JSON schema validation, generated configuration documentation comparison, and git diff --check passed.

Linux and Windows CI matrix jobs have not been independently run locally.

AI disclosure: ChatGPT assisted with defect investigation, implementation, regression tests, independent code review, and validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant