Skip to content

Conversation

@mcepl
Copy link

@mcepl mcepl commented Dec 30, 2025

Implement guard clauses to handle virtual documents (notebook cells) safely:

  • Add is_virtual_document() helper to detect non-file URIs
  • Update get_resource() to return None for virtual documents
  • Add early returns in pylsp_code_actions() and pylsp_rename() hooks
  • Prevent rope operations on virtual documents that don't correspond to files

This fixes the python-lsp-server notebook test failure where pylsp-rope was interfering with notebook cell handling by trying to treat virtual URIs as filesystem paths.

Implement guard clauses to handle virtual documents (notebook cells)
safely:

- Add is_virtual_document() helper to detect non-file URIs
- Update get_resource() to return None for virtual documents
- Add early returns in pylsp_code_actions() and pylsp_rename() hooks
- Prevent rope operations on virtual documents that don't correspond to
  files

This fixes the python-lsp-server notebook test failure where pylsp-rope
was interfering with notebook cell handling by trying to treat virtual
URIs as filesystem paths.

Signed-off-by: Matěj Cepl <[email protected]>
@mcepl mcepl force-pushed the jupyter_notebooks branch from 21510ce to e30a4d1 Compare December 30, 2025 20:39
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