Show More
@@ -193,8 +193,6 b" warnings.filterwarnings('error', category=ProvisionalCompleterWarning)" | |||
|
193 | 193 | @contextmanager |
|
194 | 194 | def provisionalcompleter(action='ignore'): |
|
195 | 195 | """ |
|
196 | ||
|
197 | ||
|
198 | 196 | This context manager has to be used in any place where unstable completer |
|
199 | 197 | behavior and API may be called. |
|
200 | 198 | |
@@ -262,17 +260,17 b' def expand_user(path:str) -> Tuple[str, bool, str]:' | |||
|
262 | 260 | Parameters |
|
263 | 261 | ---------- |
|
264 | 262 | path : str |
|
265 | String to be expanded. If no ~ is present, the output is the same as the | |
|
266 | input. | |
|
263 | String to be expanded. If no ~ is present, the output is the same as the | |
|
264 | input. | |
|
267 | 265 | |
|
268 | 266 | Returns |
|
269 | 267 | ------- |
|
270 | 268 | newpath : str |
|
271 | Result of ~ expansion in the input path. | |
|
269 | Result of ~ expansion in the input path. | |
|
272 | 270 | tilde_expand : bool |
|
273 | Whether any expansion was performed or not. | |
|
271 | Whether any expansion was performed or not. | |
|
274 | 272 | tilde_val : str |
|
275 | The value that ~ was replaced with. | |
|
273 | The value that ~ was replaced with. | |
|
276 | 274 | """ |
|
277 | 275 | # Default values |
|
278 | 276 | tilde_expand = False |
@@ -435,12 +433,9 b' def _deduplicate_completions(text: str, completions: _IC)-> _IC:' | |||
|
435 | 433 | Yields |
|
436 | 434 | ------ |
|
437 | 435 | `Completions` objects |
|
438 | ||
|
439 | ||
|
440 | 436 | Completions coming from multiple sources, may be different but end up having |
|
441 | 437 | the same effect when applied to ``text``. If this is the case, this will |
|
442 | 438 | consider completions as equal and only emit the first encountered. |
|
443 | ||
|
444 | 439 | Not folded in `completions()` yet for debugging purpose, and to detect when |
|
445 | 440 | the IPython completer does return things that Jedi does not, but should be |
|
446 | 441 | at some point. |
@@ -759,7 +754,7 b' def match_dict_keys(keys: List[Union[str, bytes, Tuple[Union[str, bytes]]]], pre' | |||
|
759 | 754 | """Used by dict_key_matches, matching the prefix to a list of keys |
|
760 | 755 | |
|
761 | 756 | Parameters |
|
762 | ========== | |
|
757 | ---------- | |
|
763 | 758 | keys: |
|
764 | 759 | list of keys in dictionary currently being completed. |
|
765 | 760 | prefix: |
@@ -767,12 +762,11 b' def match_dict_keys(keys: List[Union[str, bytes, Tuple[Union[str, bytes]]]], pre' | |||
|
767 | 762 | delims: |
|
768 | 763 | String of delimiters to consider when finding the current key. |
|
769 | 764 | extra_prefix: optional |
|
770 |
Part of the text already typed in multi-key index cases. E.g. for |
|
|
765 | Part of the text already typed in multi-key index cases. E.g. for | |
|
771 | 766 | `mydict['foo', "bar", 'b`, this would be `('foo', 'bar')`. |
|
772 | 767 | |
|
773 | 768 | Returns |
|
774 | ======= | |
|
775 | ||
|
769 | ------- | |
|
776 | 770 | A tuple of three elements: ``quote``, ``token_start``, ``matched``, with |
|
777 | 771 | ``quote`` being the quote that need to be used to close current string. |
|
778 | 772 | ``token_start`` the position where the replacement should start occurring, |
@@ -851,13 +845,11 b' def match_dict_keys(keys: List[Union[str, bytes, Tuple[Union[str, bytes]]]], pre' | |||
|
851 | 845 | |
|
852 | 846 | def cursor_to_position(text:str, line:int, column:int)->int: |
|
853 | 847 | """ |
|
854 | ||
|
855 | 848 | Convert the (line,column) position of the cursor in text to an offset in a |
|
856 | 849 | string. |
|
857 | 850 | |
|
858 | 851 | Parameters |
|
859 | 852 | ---------- |
|
860 | ||
|
861 | 853 | text : str |
|
862 | 854 | The text in which to calculate the cursor offset |
|
863 | 855 | line : int |
@@ -865,13 +857,13 b' def cursor_to_position(text:str, line:int, column:int)->int:' | |||
|
865 | 857 | column : int |
|
866 | 858 | Column of the cursor 0-indexed |
|
867 | 859 | |
|
868 | Return | |
|
869 | ------ | |
|
870 |
|
|
|
860 | Returns | |
|
861 | ------- | |
|
862 | Position of the cursor in ``text``, 0-indexed. | |
|
871 | 863 | |
|
872 | 864 | See Also |
|
873 | 865 | -------- |
|
874 | position_to_cursor: reciprocal of this function | |
|
866 | position_to_cursor : reciprocal of this function | |
|
875 | 867 | |
|
876 | 868 | """ |
|
877 | 869 | lines = text.split('\n') |
@@ -888,23 +880,20 b' def position_to_cursor(text:str, offset:int)->Tuple[int, int]:' | |||
|
888 | 880 | |
|
889 | 881 | Parameters |
|
890 | 882 | ---------- |
|
891 | ||
|
892 | 883 | text : str |
|
893 | 884 | The text in which to calculate the cursor offset |
|
894 | 885 | offset : int |
|
895 | 886 | Position of the cursor in ``text``, 0-indexed. |
|
896 | 887 | |
|
897 | Return | |
|
898 | ------ | |
|
888 | Returns | |
|
889 | ------- | |
|
899 | 890 | (line, column) : (int, int) |
|
900 | 891 | Line of the cursor; 0-indexed, column of the cursor 0-indexed |
|
901 | 892 | |
|
902 | ||
|
903 | 893 | See Also |
|
904 | 894 | -------- |
|
905 | 895 | cursor_to_position : reciprocal of this function |
|
906 | 896 | |
|
907 | ||
|
908 | 897 | """ |
|
909 | 898 | |
|
910 | 899 | assert 0 <= offset <= len(text) , "0 <= %s <= %s" % (offset , len(text)) |
@@ -994,18 +983,15 b' def _formatparamchildren(parameter) -> str:' | |||
|
994 | 983 | |
|
995 | 984 | Jedi does not expose a simple way to get `param=value` from its API. |
|
996 | 985 | |
|
997 | Parameter | |
|
998 | ========= | |
|
999 | ||
|
986 | Parameters | |
|
987 | ---------- | |
|
1000 | 988 | parameter: |
|
1001 | 989 | Jedi's function `Param` |
|
1002 | 990 | |
|
1003 | 991 | Returns |
|
1004 | ======= | |
|
1005 | ||
|
992 | ------- | |
|
1006 | 993 | A string like 'a', 'b=1', '*args', '**kwargs' |
|
1007 | 994 | |
|
1008 | ||
|
1009 | 995 | """ |
|
1010 | 996 | description = parameter.description |
|
1011 | 997 | if not description.startswith('param '): |
@@ -1017,15 +1003,13 b' def _make_signature(completion)-> str:' | |||
|
1017 | 1003 | """ |
|
1018 | 1004 | Make the signature from a jedi completion |
|
1019 | 1005 | |
|
1020 | Parameter | |
|
1021 | ========= | |
|
1022 | ||
|
1006 | Parameters | |
|
1007 | ---------- | |
|
1023 | 1008 | completion: jedi.Completion |
|
1024 | 1009 | object does not complete a function type |
|
1025 | 1010 | |
|
1026 | 1011 | Returns |
|
1027 | ======= | |
|
1028 | ||
|
1012 | ------- | |
|
1029 | 1013 | a string consisting of the function signature, with the parenthesis but |
|
1030 | 1014 | without the function name. example: |
|
1031 | 1015 | `(a, *args, b=1, **kwargs)` |
@@ -1126,20 +1110,16 b' class IPCompleter(Completer):' | |||
|
1126 | 1110 | |
|
1127 | 1111 | Parameters |
|
1128 | 1112 | ---------- |
|
1129 | ||
|
1130 | 1113 | shell |
|
1131 | 1114 | a pointer to the ipython shell itself. This is needed |
|
1132 | 1115 | because this completer knows about magic functions, and those can |
|
1133 | 1116 | only be accessed via the ipython instance. |
|
1134 | ||
|
1135 | 1117 | namespace : dict, optional |
|
1136 | 1118 | an optional dict where completions are performed. |
|
1137 | ||
|
1138 | 1119 | global_namespace : dict, optional |
|
1139 | 1120 | secondary optional dict for completions, to |
|
1140 | 1121 | handle cases (such as IPython embedded inside functions) where |
|
1141 | 1122 | both Python scopes are visible. |
|
1142 | ||
|
1143 | 1123 | use_readline : bool, optional |
|
1144 | 1124 | DEPRECATED, ignored since IPython 6.0, will have no effects |
|
1145 | 1125 | """ |
@@ -1410,7 +1390,6 b' class IPCompleter(Completer):' | |||
|
1410 | 1390 | |
|
1411 | 1391 | def _jedi_matches(self, cursor_column:int, cursor_line:int, text:str) -> Iterable[Any]: |
|
1412 | 1392 | """ |
|
1413 | ||
|
1414 | 1393 | Return a list of :any:`jedi.api.Completions` object from a ``text`` and |
|
1415 | 1394 | cursor position. |
|
1416 | 1395 | |
@@ -1425,7 +1404,6 b' class IPCompleter(Completer):' | |||
|
1425 | 1404 | |
|
1426 | 1405 | Notes |
|
1427 | 1406 | ----- |
|
1428 | ||
|
1429 | 1407 | If ``IPCompleter.debug`` is ``True`` may return a :any:`_FakeJediCompletion` |
|
1430 | 1408 | object containing a string with the Jedi debug information attached. |
|
1431 | 1409 | """ |
@@ -1866,7 +1844,6 b' class IPCompleter(Completer):' | |||
|
1866 | 1844 | |
|
1867 | 1845 | Parameters |
|
1868 | 1846 | ---------- |
|
1869 | ||
|
1870 | 1847 | text:str |
|
1871 | 1848 | Full text of the current input, multi line string. |
|
1872 | 1849 | offset:int |
@@ -1877,10 +1854,8 b' class IPCompleter(Completer):' | |||
|
1877 | 1854 | ------ |
|
1878 | 1855 | Completion |
|
1879 | 1856 | |
|
1880 | ||
|
1881 | 1857 | Notes |
|
1882 | 1858 | ----- |
|
1883 | ||
|
1884 | 1859 | The cursor on a text can either be seen as being "in between" |
|
1885 | 1860 | characters or "On" a character depending on the interface visible to |
|
1886 | 1861 | the user. For consistency the cursor being on "in between" characters X |
@@ -1890,7 +1865,6 b' class IPCompleter(Completer):' | |||
|
1890 | 1865 | Combining characters may span more that one position in the |
|
1891 | 1866 | text. |
|
1892 | 1867 | |
|
1893 | ||
|
1894 | 1868 | .. note:: |
|
1895 | 1869 | |
|
1896 | 1870 | If ``IPCompleter.debug`` is :any:`True` will yield a ``--jedi/ipython--`` |
@@ -1940,7 +1914,6 b' class IPCompleter(Completer):' | |||
|
1940 | 1914 | Core completion module.Same signature as :any:`completions`, with the |
|
1941 | 1915 | extra `timeout` parameter (in seconds). |
|
1942 | 1916 | |
|
1943 | ||
|
1944 | 1917 | Computing jedi's completion ``.type`` can be quite expensive (it is a |
|
1945 | 1918 | lazy property) and can require some warm-up, more warm up than just |
|
1946 | 1919 | computing the ``name`` of a completion. The warm-up can be : |
@@ -2029,35 +2002,30 b' class IPCompleter(Completer):' | |||
|
2029 | 2002 | Parameters |
|
2030 | 2003 | ---------- |
|
2031 | 2004 | text : string, optional |
|
2032 | Text to perform the completion on. If not given, the line buffer | |
|
2033 | is split using the instance's CompletionSplitter object. | |
|
2034 | ||
|
2005 | Text to perform the completion on. If not given, the line buffer | |
|
2006 | is split using the instance's CompletionSplitter object. | |
|
2035 | 2007 | line_buffer : string, optional |
|
2036 | If not given, the completer attempts to obtain the current line | |
|
2037 | buffer via readline. This keyword allows clients which are | |
|
2038 | requesting for text completions in non-readline contexts to inform | |
|
2039 | the completer of the entire text. | |
|
2040 | ||
|
2008 | If not given, the completer attempts to obtain the current line | |
|
2009 | buffer via readline. This keyword allows clients which are | |
|
2010 | requesting for text completions in non-readline contexts to inform | |
|
2011 | the completer of the entire text. | |
|
2041 | 2012 | cursor_pos : int, optional |
|
2042 | Index of the cursor in the full line buffer. Should be provided by | |
|
2043 | remote frontends where kernel has no access to frontend state. | |
|
2013 | Index of the cursor in the full line buffer. Should be provided by | |
|
2014 | remote frontends where kernel has no access to frontend state. | |
|
2044 | 2015 | |
|
2045 | 2016 | Returns |
|
2046 | 2017 | ------- |
|
2047 | 2018 | Tuple of two items: |
|
2048 | 2019 | text : str |
|
2049 | Text that was actually used in the completion. | |
|
2020 | Text that was actually used in the completion. | |
|
2050 | 2021 | matches : list |
|
2051 | A list of completion matches. | |
|
2052 | ||
|
2022 | A list of completion matches. | |
|
2053 | 2023 | |
|
2054 | 2024 | Notes |
|
2055 | 2025 | ----- |
|
2056 | ||
|
2057 | 2026 | This API is likely to be deprecated and replaced by |
|
2058 | 2027 | :any:`IPCompleter.completions` in the future. |
|
2059 | 2028 | |
|
2060 | ||
|
2061 | 2029 | """ |
|
2062 | 2030 | warnings.warn('`Completer.complete` is pending deprecation since ' |
|
2063 | 2031 | 'IPython 6.0 and will be replaced by `Completer.completions`.', |
@@ -2069,23 +2037,19 b' class IPCompleter(Completer):' | |||
|
2069 | 2037 | def _complete(self, *, cursor_line, cursor_pos, line_buffer=None, text=None, |
|
2070 | 2038 | full_text=None) -> _CompleteResult: |
|
2071 | 2039 | """ |
|
2072 | ||
|
2073 | 2040 | Like complete but can also returns raw jedi completions as well as the |
|
2074 | 2041 | origin of the completion text. This could (and should) be made much |
|
2075 | 2042 | cleaner but that will be simpler once we drop the old (and stateful) |
|
2076 | 2043 | :any:`complete` API. |
|
2077 | 2044 | |
|
2078 | ||
|
2079 | 2045 | With current provisional API, cursor_pos act both (depending on the |
|
2080 | 2046 | caller) as the offset in the ``text`` or ``line_buffer``, or as the |
|
2081 | 2047 | ``column`` when passing multiline strings this could/should be renamed |
|
2082 | 2048 | but would add extra noise. |
|
2083 | 2049 | |
|
2084 | Return | |
|
2085 | ====== | |
|
2086 | ||
|
2050 | Returns | |
|
2051 | ------- | |
|
2087 | 2052 | A tuple of N elements which are (likely): |
|
2088 | ||
|
2089 | 2053 | matched_text: ? the text that the complete matched |
|
2090 | 2054 | matches: list of completions ? |
|
2091 | 2055 | matches_origin: ? list same lenght as matches, and where each completion came from |
@@ -2191,15 +2155,13 b' class IPCompleter(Completer):' | |||
|
2191 | 2155 | |
|
2192 | 2156 | def fwd_unicode_match(self, text:str) -> Tuple[str, Sequence[str]]: |
|
2193 | 2157 | """ |
|
2194 | ||
|
2195 | 2158 | Forward match a string starting with a backslash with a list of |
|
2196 | 2159 | potential Unicode completions. |
|
2197 | 2160 | |
|
2198 | 2161 | Will compute list list of Unicode character names on first call and cache it. |
|
2199 | 2162 | |
|
2200 | Return | |
|
2201 | ====== | |
|
2202 | ||
|
2163 | Returns | |
|
2164 | ------- | |
|
2203 | 2165 | At tuple with: |
|
2204 | 2166 | - matched text (empty if no matches) |
|
2205 | 2167 | - list of potential completions, empty tuple otherwise) |
General Comments 0
You need to be logged in to leave comments.
Login now