2 Commits

Author SHA1 Message Date
WutingjiaX
29a41c013b Merge be6df62434 into e53359ad88 2024-10-17 11:21:16 +00:00
wutingjia
be6df62434 filter imported names during completion 2024-10-17 19:20:39 +08:00
2 changed files with 8 additions and 1 deletions

View File

@@ -455,6 +455,7 @@ class Completion:
- Having some doctest code that starts with `>>>`
- Having backticks that doesn't have whitespace inside it
"""
def iter_relevant_lines(lines):
include_next_line = False
for l in code_lines:
@@ -683,8 +684,11 @@ def extract_imported_names(node):
imported_names = []
if node.type in ['import_as_names', 'dotted_as_names', 'import_as_name']:
for child in node.children:
for index, child in enumerate(node.children):
if child.type == 'name':
if (index > 0 and node.children[index - 1].type == "keyword"
and node.children[index - 1].value == "as"):
continue
imported_names.append(child.value)
elif child.type == 'import_as_name':
imported_names.extend(extract_imported_names(child))

View File

@@ -325,6 +325,9 @@ def test_duplicated_import(Script):
s = 'from os import path as pp, p'
assert 'path' not in import_names(s)
s = 'from os import chdir as path, p'
assert 'path' in import_names(s)
def test_path_issues(Script):
"""