settings.py 3.7 KB

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