8
8
arguments.
9
9
"""
10
10
import sys
11
- import warnings
12
11
from pathlib import Path
13
12
14
13
import parso
@@ -90,51 +89,23 @@ class Script(object):
90
89
91
90
:param code: The source code of the current file, separated by newlines.
92
91
:type code: str
93
- :param line: Deprecated, please use it directly on e.g. ``.complete``
94
- :type line: int
95
- :param column: Deprecated, please use it directly on e.g. ``.complete``
96
- :type column: int
97
92
:param path: The path of the file in the file system, or ``''`` if
98
93
it hasn't been saved yet.
99
94
:type path: str or pathlib.Path or None
100
- :param sys_path: Deprecated, use the project parameter.
101
- :type sys_path: typing.List[str]
102
95
:param Environment environment: Provide a predefined :ref:`Environment <environments>`
103
96
to work with a specific Python version or virtualenv.
104
97
:param Project project: Provide a :class:`.Project` to make sure finding
105
98
references works well, because the right folder is searched. There are
106
99
also ways to modify the sys path and other things.
107
100
"""
108
- def __init__ (self , code = None , line = None , column = None , path = None ,
109
- sys_path = None , environment = None , project = None , source = None ):
101
+ def __init__ (self , code = None , * , path = None , environment = None , project = None ):
110
102
self ._orig_path = path
111
103
# An empty path (also empty string) should always result in no path.
112
104
if isinstance (path , str ):
113
105
path = Path (path )
114
106
115
107
self .path = path .absolute () if path else None
116
108
117
- if line is not None :
118
- warnings .warn (
119
- "Providing the line is now done in the functions themselves "
120
- "like `Script(...).complete(line, column)`" ,
121
- DeprecationWarning ,
122
- stacklevel = 2
123
- )
124
- if column is not None :
125
- warnings .warn (
126
- "Providing the column is now done in the functions themselves "
127
- "like `Script(...).complete(line, column)`" ,
128
- DeprecationWarning ,
129
- stacklevel = 2
130
- )
131
- if source is not None :
132
- code = source
133
- warnings .warn (
134
- "Use the code keyword argument instead." ,
135
- DeprecationWarning ,
136
- stacklevel = 2
137
- )
138
109
if code is None :
139
110
# TODO add a better warning than the traceback!
140
111
with open (path , 'rb' ) as f :
@@ -143,15 +114,6 @@ def __init__(self, code=None, line=None, column=None, path=None,
143
114
if project is None :
144
115
# Load the Python grammar of the current interpreter.
145
116
project = get_default_project (None if self .path is None else self .path .parent )
146
- # TODO deprecate and remove sys_path from the Script API.
147
- if sys_path is not None :
148
- project ._sys_path = sys_path
149
- warnings .warn (
150
- "Deprecated since version 0.17.0. Use the project API instead, "
151
- "which means Script(project=Project(dir, sys_path=sys_path)) instead." ,
152
- DeprecationWarning ,
153
- stacklevel = 2
154
- )
155
117
156
118
self ._inference_state = InferenceState (
157
119
project , environment = environment , script_path = self .path
@@ -168,7 +130,6 @@ def __init__(self, code=None, line=None, column=None, path=None,
168
130
debug .speed ('parsed' )
169
131
self ._code_lines = parso .split_lines (code , keepends = True )
170
132
self ._code = code
171
- self ._pos = line , column
172
133
173
134
cache .clear_time_caches ()
174
135
debug .reset_time ()
@@ -250,14 +211,6 @@ def complete(self, line=None, column=None, *, fuzzy=False):
250
211
)
251
212
return completion .complete ()
252
213
253
- def completions (self , fuzzy = False ):
254
- warnings .warn (
255
- "Deprecated since version 0.16.0. Use Script(...).complete instead." ,
256
- DeprecationWarning ,
257
- stacklevel = 2
258
- )
259
- return self .complete (* self ._pos , fuzzy = fuzzy )
260
-
261
214
@validate_line_column
262
215
def infer (self , line = None , column = None , * , only_stubs = False , prefer_stubs = False ):
263
216
"""
@@ -297,25 +250,6 @@ def infer(self, line=None, column=None, *, only_stubs=False, prefer_stubs=False)
297
250
# the API.
298
251
return helpers .sorted_definitions (set (defs ))
299
252
300
- def goto_definitions (self , ** kwargs ):
301
- warnings .warn (
302
- "Deprecated since version 0.16.0. Use Script(...).infer instead." ,
303
- DeprecationWarning ,
304
- stacklevel = 2
305
- )
306
- return self .infer (* self ._pos , ** kwargs )
307
-
308
- def goto_assignments (self , follow_imports = False , follow_builtin_imports = False , ** kwargs ):
309
- warnings .warn (
310
- "Deprecated since version 0.16.0. Use Script(...).goto instead." ,
311
- DeprecationWarning ,
312
- stacklevel = 2
313
- )
314
- return self .goto (* self ._pos ,
315
- follow_imports = follow_imports ,
316
- follow_builtin_imports = follow_builtin_imports ,
317
- ** kwargs )
318
-
319
253
@validate_line_column
320
254
def goto (self , line = None , column = None , * , follow_imports = False , follow_builtin_imports = False ,
321
255
only_stubs = False , prefer_stubs = False ):
@@ -446,14 +380,6 @@ def need_pydoc():
446
380
return [classes .Name (self ._inference_state , name )]
447
381
return []
448
382
449
- def usages (self , ** kwargs ):
450
- warnings .warn (
451
- "Deprecated since version 0.16.0. Use Script(...).get_references instead." ,
452
- DeprecationWarning ,
453
- stacklevel = 2
454
- )
455
- return self .get_references (* self ._pos , ** kwargs )
456
-
457
383
@validate_line_column
458
384
def get_references (self , line = None , column = None , ** kwargs ):
459
385
"""
@@ -484,14 +410,6 @@ def _references(include_builtins=True, scope='project'):
484
410
return helpers .sorted_definitions (definitions )
485
411
return _references (** kwargs )
486
412
487
- def call_signatures (self ):
488
- warnings .warn (
489
- "Deprecated since version 0.16.0. Use Script(...).get_signatures instead." ,
490
- DeprecationWarning ,
491
- stacklevel = 2
492
- )
493
- return self .get_signatures (* self ._pos )
494
-
495
413
@validate_line_column
496
414
def get_signatures (self , line = None , column = None ):
497
415
"""
@@ -817,21 +735,6 @@ def _get_module_context(self):
817
735
)
818
736
819
737
820
- def names (source = None , path = None , all_scopes = False ,
821
- definitions = True , references = False , environment = None ):
822
- warnings .warn (
823
- "Deprecated since version 0.16.0. Use Script(...).get_names instead." ,
824
- DeprecationWarning ,
825
- stacklevel = 2
826
- )
827
-
828
- return Script (source , path = path ).get_names (
829
- all_scopes = all_scopes ,
830
- definitions = definitions ,
831
- references = references ,
832
- )
833
-
834
-
835
738
def preload_module (* modules ):
836
739
"""
837
740
Preloading modules tells Jedi to load a module now, instead of lazy parsing
0 commit comments