From f871f5e726f796127d4cfb981726b494f056ebe9 Mon Sep 17 00:00:00 2001 From: xu0o0 Date: Fri, 17 Apr 2020 17:33:44 +0800 Subject: [PATCH] fix #1548 --- jedi/api/__init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 0a385eff..591dd19e 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -128,15 +128,6 @@ class Script(object): # An empty path (also empty string) should always result in no path. self.path = os.path.abspath(path) if path else None - # TODO deprecate and remove sys_path from the Script API. - if sys_path is not None: - project._sys_path = sys_path - warnings.warn( - "Deprecated since version 0.17.0. Use the project API instead, " - "which means Script(project=Project(dir, sys_path=sys_path)) instead.", - DeprecationWarning, - stacklevel=2 - ) if encoding is None: encoding = 'utf-8' else: @@ -180,6 +171,15 @@ class Script(object): project = get_default_project( os.path.dirname(self.path) if path else None ) + # TODO deprecate and remove sys_path from the Script API. + if sys_path is not None: + project._sys_path = sys_path + warnings.warn( + "Deprecated since version 0.17.0. Use the project API instead, " + "which means Script(project=Project(dir, sys_path=sys_path)) instead.", + DeprecationWarning, + stacklevel=2 + ) self._inference_state = InferenceState( project, environment=environment, script_path=self.path