Skip to content

Commit b8f544e

Browse files
committed
apply code review
1 parent c7349d6 commit b8f544e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pylsp/plugins/symbols.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def pylsp_document_symbols(config, document):
2020
symbols = []
2121
exclude = set({})
2222
redefinitions = {}
23+
pattern_import = (
24+
re.compile
25+
(r'^\s*(?!#)\s*(from\s+[.\w]+(\.[\w]+)*\s+import\s+[\w\s,()*]+|import\s+[\w\s,.*]+)')
26+
)
2327

2428
while definitions != []:
2529
d = definitions.pop(0)
@@ -28,11 +32,8 @@ def pylsp_document_symbols(config, document):
2832
if not add_import_symbols:
2933
# Skip if there's an import in the code the symbol is defined.
3034
code = d.get_line_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):
35+
36+
if pattern_import.match(code):
3637
continue
3738

3839
# Skip imported symbols comparing module names.

0 commit comments

Comments
 (0)