8000 Fix Inline Comments · python-lsp/python-lsp-server@c7349d6 · GitHub
[go: up one dir, main page]

Skip to content

Commit c7349d6

Browse files
committed
Fix Inline Comments
1 parent 04fa3e5 commit c7349d6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pylsp/plugins/symbols.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright 2021- Python Language Server Contributors.
33

44
import logging
5+
import re
56
from pathlib import Path
67

78
from pylsp import hookimpl
@@ -27,7 +28,11 @@ def pylsp_document_symbols(config, document):
2728
if not add_import_symbols:
2829
# Skip if there's an import in the code the symbol is defined.
2930
code = d.get_line_code()
30-
if " import " in code or "import " in code:
31+
pattern = (
32+
re.compile
33+
(r'^\s*(?!#)(from\s+\w+(\.\w+)*\s+import\s+[\w,\s*]+|import\s+[\w,\s]+)')
34+
)
35+
if pattern.match(code):
3136
continue
3237

3338
# Skip imported symbols comparing module names.

0 commit comments

Comments
 (0)
0