mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Make it possible to complete in non-Python files
This commit is contained in:
@@ -210,9 +210,9 @@ def transform_path_to_dotted(sys_path, module_path):
|
|||||||
if module_path.endswith(suffix):
|
if module_path.endswith(suffix):
|
||||||
module_path = module_path[:-len(suffix)]
|
module_path = module_path[:-len(suffix)]
|
||||||
break
|
break
|
||||||
else:
|
# Once the suffix was removed we are using the files as we know them. This
|
||||||
# There should always be a suffix in a valid Python file on the path.
|
# means that if someone uses an ending like .vim for a Python file, .vim
|
||||||
return None
|
# will be part of the returned dotted part.
|
||||||
|
|
||||||
for p in sys_path:
|
for p in sys_path:
|
||||||
if module_path.startswith(p):
|
if module_path.startswith(p):
|
||||||
|
|||||||
@@ -254,11 +254,13 @@ def test_compiled_import_none(monkeypatch, Script):
|
|||||||
assert not Script('import sys').goto_definitions()
|
assert not Script('import sys').goto_definitions()
|
||||||
|
|
||||||
|
|
||||||
def test_relative_imports_with_multiple_similar_directories(Script):
|
@pytest.mark.parametrize(
|
||||||
|
'path', ('api/whatever/test_this.py', 'api/whatever/file'))
|
||||||
|
def test_relative_imports_with_multiple_similar_directories(Script, path):
|
||||||
dir = get_example_dir('issue1209')
|
dir = get_example_dir('issue1209')
|
||||||
script = Script(
|
script = Script(
|
||||||
"from .",
|
"from .",
|
||||||
path=os.path.join(dir, 'api/whatever/test_this.py')
|
path=os.path.join(dir, path)
|
||||||
)
|
)
|
||||||
# TODO pass this project to the script as a param once that's possible.
|
# TODO pass this project to the script as a param once that's possible.
|
||||||
script._evaluator.project = Project(dir)
|
script._evaluator.project = Project(dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user