Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/jedi/settings.py: 90%

20 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-20 06:09 +0000

1""" 

2This module contains variables with global |jedi| settings. To change the 

3behavior of |jedi|, change the variables defined in :mod:`jedi.settings`. 

4 

5Plugins should expose an interface so that the user can adjust the 

6configuration. 

7 

8 

9Example usage:: 

10 

11 from jedi import settings 

12 settings.case_insensitive_completion = True 

13 

14 

15Completion output 

16~~~~~~~~~~~~~~~~~ 

17 

18.. autodata:: case_insensitive_completion 

19.. autodata:: add_bracket_after_function 

20 

21 

22Filesystem cache 

23~~~~~~~~~~~~~~~~ 

24 

25.. autodata:: cache_directory 

26 

27 

28Parser 

29~~~~~~ 

30 

31.. autodata:: fast_parser 

32 

33 

34Dynamic 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 

43Caching 

44~~~~~~~ 

45 

46.. autodata:: call_signatures_validity 

47 

48 

49""" 

50import os 

51import platform 

52 

53# ---------------- 

54# Completion Output Settings 

55# ---------------- 

56 

57case_insensitive_completion = True 

58""" 

59Completions are by default case insensitive. 

60""" 

61 

62add_bracket_after_function = False 

63""" 

64Adds an opening bracket after a function for completions. 

65""" 

66 

67# ---------------- 

68# Filesystem Cache 

69# ---------------- 

70 

71if platform.system().lower() == 'windows': 

72 _cache_directory = os.path.join( 

73 os.getenv('LOCALAPPDATA') or os.path.expanduser('~'), 

74 'Jedi', 

75 'Jedi', 

76 ) 

77elif platform.system().lower() == 'darwin': 

78 _cache_directory = os.path.join('~', 'Library', 'Caches', 'Jedi') 

79else: 

80 _cache_directory = os.path.join(os.getenv('XDG_CACHE_HOME') or '~/.cache', 

81 'jedi') 

82cache_directory = os.path.expanduser(_cache_directory) 

83""" 

84The path where the cache is stored. 

85 

86On Linux, this defaults to ``~/.cache/jedi/``, on OS X to 

87``~/Library/Caches/Jedi/`` and on Windows to ``%LOCALAPPDATA%\\Jedi\\Jedi\\``. 

88On 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# Parser 

94# ---------------- 

95 

96fast_parser = True 

97""" 

98Uses Parso's diff parser. If it is enabled, this might cause issues, please 

99read the warning on :class:`.Script`. This feature makes it possible to only 

100parse the parts again that have changed, while reusing the rest of the syntax 

101tree. 

102""" 

103 

104_cropped_file_size = int(10e6) # 1 Megabyte 

105""" 

106Jedi gets extremely slow if the file size exceed a few thousand lines. 

107To avoid getting stuck completely Jedi crops the file at some point. 

108 

109One megabyte of typical Python code equals about 20'000 lines of code. 

110""" 

111 

112# ---------------- 

113# Dynamic Stuff 

114# ---------------- 

115 

116dynamic_array_additions = True 

117""" 

118check for `append`, etc. on arrays: [], {}, () as well as list/set calls. 

119""" 

120 

121dynamic_params = True 

122""" 

123A dynamic param completion, finds the callees of the function, which define 

124the params of a function. 

125""" 

126 

127dynamic_params_for_other_modules = True 

128""" 

129Do the same for other modules. 

130""" 

131 

132dynamic_flow_information = True 

133""" 

134Check for `isinstance` and other information to infer a type. 

135""" 

136 

137auto_import_modules = [ 

138 'gi', # This third-party repository (GTK stuff) doesn't really work with jedi 

139] 

140""" 

141Modules that will not be analyzed but imported, if they contain Python code. 

142This improves autocompletion for libraries that use ``setattr`` or 

143``globals()`` modifications a lot. 

144""" 

145 

146allow_unsafe_interpreter_executions = True 

147""" 

148Controls whether descriptors are evaluated when using an Interpreter. This is 

149something you might want to control when using Jedi from a Repl (e.g. IPython) 

150 

151Generally this setting allows Jedi to execute __getitem__ and descriptors like 

152`property`. 

153""" 

154 

155# ---------------- 

156# Caching Validity 

157# ---------------- 

158 

159call_signatures_validity = 3.0 

160""" 

161Finding function calls might be slow (0.1-0.5s). This is not acceptible for 

162normal writing. Therefore cache it for a short time. 

163"""