Skip to content

Fix inline comments that include text with import #639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
jsbautista committed May 15, 2025
commit 2d307c529d240fbcf2f60ab9c9c5c369441ee620
27 changes: 27 additions & 0 deletions test/plugins/test_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ def main(x):

"""

DOC_IMPORTS = """from . import something
from ..module import something
from module import (a, b)

def main():
# import ignored
print("from module import x") # string with import
return something

"""


def helper_check_symbols_all_scope(symbols):
# All eight symbols (import sys, a, B, __init__, x, y, main, y)
Expand Down Expand Up @@ -73,6 +84,22 @@ def sym(name):
assert sym("main")["location"]["range"]["end"] == {"line": 12, "character": 0}


def test_symbols_complex_imports(config, workspace):
doc = Document(DOC_URI, workspace, DOC_IMPORTS)
config.update({"plugins": {"jedi_symbols": {"all_scopes": False}}})
symbols = pylsp_document_symbols(config, doc)

import_symbols = [s for s in symbols if s["kind"] == SymbolKind.Module]

assert len(import_symbols) == 4

names = [s["name"] for s in import_symbols]
assert "something" in names
assert "a" in names or "b" in names

assert any(s["name"] == "main" and s["kind"] == SymbolKind.Function for s in symbols)


def test_symbols_all_scopes(config, workspace) -> None:
doc = Document(DOC_URI, workspace, DOC)
symbols = pylsp_document_symbols(config, doc)
Expand Down