1
0
forked from VimPlug/jedi

Add Project.path, fixes #1622

This commit is contained in:
Dave Halter
2020-06-27 00:43:19 +02:00
parent bc23458164
commit 344fef1e2f
5 changed files with 12 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ Unreleased
++++++++++ ++++++++++
- Added an option to pass environment variables to ``Environment`` - Added an option to pass environment variables to ``Environment``
- ``Project(...).path`` exists now
0.17.1 (2020-06-20) 0.17.1 (2020-06-20)
+++++++++++++++++++ +++++++++++++++++++

View File

@@ -36,7 +36,7 @@ def complete_file_name(inference_state, module_context, start_leaf, quote, strin
is_in_os_path_join = False is_in_os_path_join = False
else: else:
string = to_be_added + string string = to_be_added + string
base_path = os.path.join(inference_state.project._path, string) base_path = os.path.join(inference_state.project.path, string)
try: try:
listed = sorted(scandir(base_path), key=lambda e: e.name) listed = sorted(scandir(base_path), key=lambda e: e.name)
# OSError: [Errno 36] File name too long: '...' # OSError: [Errno 36] File name too long: '...'

View File

@@ -150,6 +150,13 @@ class Project(object):
py2_comp(path, **kwargs) py2_comp(path, **kwargs)
@property
def path(self):
"""
The base path for this project.
"""
return self._path
@inference_state_as_method_param_cache() @inference_state_as_method_param_cache()
def _get_base_sys_path(self, inference_state): def _get_base_sys_path(self, inference_state):
# The sys path has not been set explicitly. # The sys path has not been set explicitly.

View File

@@ -39,7 +39,7 @@ class ChangedFile(object):
if new_lines[-1] != '': if new_lines[-1] != '':
new_lines[-1] += '\n' new_lines[-1] += '\n'
project_path = self._inference_state.project._path project_path = self._inference_state.project.path
if self._from_path is None: if self._from_path is None:
from_p = '' from_p = ''
else: else:
@@ -112,7 +112,7 @@ class Refactoring(object):
def get_diff(self): def get_diff(self):
text = '' text = ''
project_path = self._inference_state.project._path project_path = self._inference_state.project.path
for from_, to in self.get_renames(): for from_, to in self.get_renames():
text += 'rename from %s\nrename to %s\n' \ text += 'rename from %s\nrename to %s\n' \
% (relpath(from_, project_path), relpath(to, project_path)) % (relpath(from_, project_path), relpath(to, project_path))

View File

@@ -192,7 +192,7 @@ class Importer(object):
import_path = base + tuple(import_path) import_path = base + tuple(import_path)
else: else:
path = module_context.py__file__() path = module_context.py__file__()
project_path = self._inference_state.project._path project_path = self._inference_state.project.path
import_path = list(import_path) import_path = list(import_path)
if path is None: if path is None:
# If no path is defined, our best guess is that the current # If no path is defined, our best guess is that the current