| 1 |
""" |
| 2 |
This module contains variables with global |jedi| settings. To change the |
| 3 |
behavior of |jedi|, change the variables defined in :mod:`jedi.settings`. |
| 4 |
|
| 5 |
Plugins should expose an interface so that the user can adjust the |
| 6 |
configuration. |
| 7 |
|
| 8 |
|
| 9 |
Example usage:: |
| 10 |
|
| 11 |
from jedi import settings |
| 12 |
settings.case_insensitive_completion = True |
| 13 |
|
| 14 |
|
| 15 |
Completion output |
| 16 |
~~~~~~~~~~~~~~~~~ |
| 17 |
|
| 18 |
.. autodata:: case_insensitive_completion |
| 19 |
.. autodata:: add_bracket_after_function |
| 20 |
|
| 21 |
|
| 22 |
Filesystem cache |
| 23 |
~~~~~~~~~~~~~~~~ |
| 24 |
|
| 25 |
.. autodata:: cache_directory |
| 26 |
|
| 27 |
|
| 28 |
Parser |
| 29 |
~~~~~~ |
| 30 |
|
| 31 |
.. autodata:: fast_parser |
| 32 |
|
| 33 |
|
| 34 |
Dynamic stuff |
| 35 |
~~~~~~~~~~~~~ |
| 36 |
|
| 37 |
.. autodata:: dynamic_array_additions |
| 38 |
.. autodata:: dynamic_params |
| 39 |
.. autodata:: dynamic_params_for_other_modules |
| 40 |
.. autodata:: auto_import_modules |
| 41 |
|
| 42 |
|
| 43 |
Caching |
| 44 |
~~~~~~~ |
| 45 |
|
| 46 |
.. autodata:: call_signatures_validity |
| 47 |
|
| 48 |
|
| 49 |
""" |
| 50 |
import os |
| 51 |
import platform |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
case_insensitive_completion = True |
| 58 |
""" |
| 59 |
Completions are by default case insensitive. |
| 60 |
""" |
| 61 |
|
| 62 |
add_bracket_after_function = False |
| 63 |
""" |
| 64 |
Adds an opening bracket after a function for completions. |
| 65 |
""" |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
if platform.system().lower() == 'windows': |
| 72 |
_cache_directory = os.path.join( |
| 73 |
os.getenv('LOCALAPPDATA') or os.path.expanduser('~'), |
| 74 |
'Jedi', |
| 75 |
'Jedi', |
| 76 |
) |
| 77 |
elif platform.system().lower() == 'darwin': |
| 78 |
_cache_directory = os.path.join('~', 'Library', 'Caches', 'Jedi') |
| 79 |
else: |
| 80 |
_cache_directory = os.path.join(os.getenv('XDG_CACHE_HOME') or '~/.cache', |
| 81 |
'jedi') |
| 82 |
cache_directory = os.path.expanduser(_cache_directory) |
| 83 |
""" |
| 84 |
The path where the cache is stored. |
| 85 |
|
| 86 |
On Linux, this defaults to ``~/.cache/jedi/``, on OS X to |
| 87 |
``~/Library/Caches/Jedi/`` and on Windows to ``%LOCALAPPDATA%\\Jedi\\Jedi\\``. |
| 88 |
On Linux, if the environment variable ``$XDG_CACHE_HOME`` is set, |
| 89 |
``$XDG_CACHE_HOME/jedi`` is used instead of the default one. |
| 90 |
""" |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
fast_parser = True |
| 97 |
""" |
| 98 |
Uses Parso's diff parser. If it is enabled, this might cause issues, please |
| 99 |
read the warning on :class:`.Script`. This feature makes it possible to only |
| 100 |
parse the parts again that have changed, while reusing the rest of the syntax |
| 101 |
tree. |
| 102 |
""" |
| 103 |
|
| 104 |
_cropped_file_size = int(10e6) |
| 105 |
""" |
| 106 |
Jedi gets extremely slow if the file size exceed a few thousand lines. |
| 107 |
To avoid getting stuck completely Jedi crops the file at some point. |
| 108 |
|
| 109 |
One megabyte of typical Python code equals about 20'000 lines of code. |
| 110 |
""" |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
dynamic_array_additions = True |
| 117 |
""" |
| 118 |
check for `append`, etc. on arrays: [], {}, () as well as list/set calls. |
| 119 |
""" |
| 120 |
|
| 121 |
dynamic_params = True |
| 122 |
""" |
| 123 |
A dynamic param completion, finds the callees of the function, which define |
| 124 |
the params of a function. |
| 125 |
""" |
| 126 |
|
| 127 |
dynamic_params_for_other_modules = True |
| 128 |
""" |
| 129 |
Do the same for other modules. |
| 130 |
""" |
| 131 |
|
| 132 |
dynamic_flow_information = True |
| 133 |
""" |
| 134 |
Check for `isinstance` and other information to infer a type. |
| 135 |
""" |
| 136 |
|
| 137 |
auto_import_modules = [ |
| 138 |
'gi', |
| 139 |
] |
| 140 |
""" |
| 141 |
Modules that will not be analyzed but imported, if they contain Python code. |
| 142 |
This improves autocompletion for libraries that use ``setattr`` or |
| 143 |
``globals()`` modifications a lot. |
| 144 |
""" |
| 145 |
|
| 146 |
allow_unsafe_interpreter_executions = True |
| 147 |
""" |
| 148 |
Controls whether descriptors are evaluated when using an Interpreter. This is |
| 149 |
something you might want to control when using Jedi from a Repl (e.g. IPython) |
| 150 |
|
| 151 |
Generally this setting allows Jedi to execute __getitem__ and descriptors like |
| 152 |
`property`. |
| 153 |
""" |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
call_signatures_validity = 3.0 |
| 160 |
""" |
| 161 |
Finding function calls might be slow (0.1-0.5s). This is not acceptible for |
| 162 |
normal writing. Therefore cache it for a short time. |
| 163 |
""" |