Show More
@@ -193,8 +193,6 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 | |
@@ -435,12 +433,9 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 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: |
@@ -771,8 +766,7 def match_dict_keys(keys: List[Union[str, bytes, Tuple[Union[str, bytes]]]], pre | |||
|
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 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,8 +857,8 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 | ------ | |
|
860 | Returns | |
|
861 | ------- | |
|
870 | 862 |
|
|
871 | 863 | |
|
872 | 864 | See Also |
@@ -888,23 +880,20 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 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 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 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 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 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 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 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 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 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 : |
@@ -2031,13 +2004,11 class IPCompleter(Completer): | |||
|
2031 | 2004 | text : string, optional |
|
2032 | 2005 | Text to perform the completion on. If not given, the line buffer |
|
2033 | 2006 | is split using the instance's CompletionSplitter object. |
|
2034 | ||
|
2035 | 2007 | line_buffer : string, optional |
|
2036 | 2008 | If not given, the completer attempts to obtain the current line |
|
2037 | 2009 | buffer via readline. This keyword allows clients which are |
|
2038 | 2010 | requesting for text completions in non-readline contexts to inform |
|
2039 | 2011 | the completer of the entire text. |
|
2040 | ||
|
2041 | 2012 | cursor_pos : int, optional |
|
2042 | 2013 | Index of the cursor in the full line buffer. Should be provided by |
|
2043 | 2014 | remote frontends where kernel has no access to frontend state. |
@@ -2050,14 +2021,11 class IPCompleter(Completer): | |||
|
2050 | 2021 | matches : list |
|
2051 | 2022 | A list of completion matches. |
|
2052 | 2023 | |
|
2053 | ||
|
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 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 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