Skip to content

Skip pathless definitions when collecting document symbols - #727

Closed
Eric3-jp wants to merge 1 commit into
python-lsp:developfrom
Eric3-jp:fix/symbols-without-source-path
Closed

Eric3-jp wants to merge 1 commit into
python-lsp:developfrom
Eric3-jp:fix/symbols-without-source-path

Conversation

@Eric3-jp

Copy link
Copy Markdown

Importing a collections.namedtuple from another module can make document symbols return an empty result. Jedi reports the imported class in the current document, but its generated members have module_path=None, so processing those members raises TypeError in Path(None) before the remaining local symbols are returned.

Skip definitions without a source path before comparing paths. This preserves the imported class and the rest of the document's symbols while respecting include_import_symbols. The regression uses real files and Jedi, covering both values of all_scopes and include_import_symbols.

Fixes #635.

Validation on Python 3.11.16 / Linux (WSL), with Jedi 0.20.0:

  • The four regression cases produced 2 failures and 2 passes before the fix; all four pass afterward.
  • Full CI=true pytest -q test/, including the separate /tmp/pyenv environment required by the CI workflow: 206 passed, 9 skipped.
  • Ruff 0.9.4 lint and formatting checks pass for pylsp and test.
  • JSON schema validation and generated configuration documentation comparison pass.

This contribution was prepared with OpenAI Codex. The behavior and validation above were reproduced locally.

@Eric3-jp Eric3-jp closed this by deleting the head repository Sep 23, 2026
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.

textDocument/documentSymbol causes pylsp_document_symbols to throw a TypeError when there is an import for a namedtuple type

1 participant