forked from VimPlug/jedi
Use pathlib for file ios, because the new parso is out
This commit is contained in:
@@ -4,6 +4,7 @@ Used only for REPL Completion.
|
||||
|
||||
import inspect
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from jedi.parser_utils import get_cached_code_lines
|
||||
|
||||
@@ -190,7 +191,8 @@ def _find_syntax_node_name(inference_state, python_object):
|
||||
except TypeError:
|
||||
# The type might not be known (e.g. class_with_dict.__weakref__)
|
||||
return None
|
||||
if path is None or not os.path.exists(path):
|
||||
path = None if path is None else Path(path)
|
||||
if path is None or not path.exists():
|
||||
# The path might not exist or be e.g. <stdin>.
|
||||
return None
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
import inspect
|
||||
import importlib
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from zipimport import zipimporter
|
||||
from importlib.machinery import all_suffixes
|
||||
|
||||
@@ -211,7 +212,7 @@ def _from_loader(loader, string):
|
||||
if code is None:
|
||||
return None, is_package
|
||||
if isinstance(loader, zipimporter):
|
||||
return ZipFileIO(module_path, code, cast_path(loader.archive)), is_package
|
||||
return ZipFileIO(module_path, code, Path(cast_path(loader.archive))), is_package
|
||||
|
||||
return KnownContentFileIO(module_path, code), is_package
|
||||
|
||||
|
||||
@@ -203,11 +203,11 @@ def recurse_find_python_folders_and_files(folder_io, except_paths=()):
|
||||
# Delete folders that we don't want to iterate over.
|
||||
for file_io in file_ios:
|
||||
path = file_io.path
|
||||
if path.endswith('.py') or path.endswith('.pyi'):
|
||||
if path.suffix in ('.py', '.pyi'):
|
||||
if path not in except_paths:
|
||||
yield None, file_io
|
||||
|
||||
if path.endswith('.gitignore'):
|
||||
if path.name == '.gitignore':
|
||||
ignored_paths, ignored_names = \
|
||||
gitignored_lines(root_folder_io, file_io)
|
||||
except_paths |= ignored_paths
|
||||
|
||||
@@ -164,7 +164,7 @@ def _get_paths_from_buildout_script(inference_state, buildout_script_path):
|
||||
inference_state, module_node,
|
||||
file_io=file_io,
|
||||
string_names=None,
|
||||
code_lines=get_cached_code_lines(inference_state.grammar, str(buildout_script_path)),
|
||||
code_lines=get_cached_code_lines(inference_state.grammar, buildout_script_path),
|
||||
).as_context()
|
||||
yield from check_sys_path_modifications(module_context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user