We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 04fa3e5 commit c7349d6Copy full SHA for c7349d6
pylsp/plugins/symbols.py
@@ -2,6 +2,7 @@
2
# Copyright 2021- Python Language Server Contributors.
3
4
import logging
5
+import re
6
from pathlib import Path
7
8
from pylsp import hookimpl
@@ -27,7 +28,11 @@ def pylsp_document_symbols(config, document):
27
28
if not add_import_symbols:
29
# Skip if there's an import in the code the symbol is defined.
30
code = d.get_line_code()
- 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):
36
continue
37
38
# Skip imported symbols comparing module names.
0 commit comments