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