Show More
@@ -350,7 +350,7 b' class Completion:' | |||
|
350 | 350 | Completion object used and return by IPython completers. |
|
351 | 351 | |
|
352 | 352 | .. warning:: Unstable |
|
353 | ||
|
353 | ||
|
354 | 354 | This function is unstable, API may change without warning. |
|
355 | 355 | It will also raise unless use in proper context manager. |
|
356 | 356 | |
@@ -591,7 +591,7 b' class Completer(Configurable):' | |||
|
591 | 591 | 'information for experimental jedi integration.')\ |
|
592 | 592 | .tag(config=True) |
|
593 | 593 | |
|
594 |
backslash_combining_completions = Bool(True, |
|
|
594 | backslash_combining_completions = Bool(True, | |
|
595 | 595 | help="Enable unicode completions, e.g. \\alpha<tab> . " |
|
596 | 596 | "Includes completion of latex commands, unicode names, and expanding " |
|
597 | 597 | "unicode characters back to latex commands.").tag(config=True) |
@@ -693,7 +693,7 b' class Completer(Configurable):' | |||
|
693 | 693 | |
|
694 | 694 | # Another option, seems to work great. Catches things like ''.<tab> |
|
695 | 695 | m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text) |
|
696 | ||
|
696 | ||
|
697 | 697 | if m: |
|
698 | 698 | expr, attr = m.group(1, 3) |
|
699 | 699 | elif self.greedy: |
@@ -703,7 +703,7 b' class Completer(Configurable):' | |||
|
703 | 703 | expr, attr = m2.group(1,2) |
|
704 | 704 | else: |
|
705 | 705 | return [] |
|
706 | ||
|
706 | ||
|
707 | 707 | try: |
|
708 | 708 | obj = eval(expr, self.namespace) |
|
709 | 709 | except: |
@@ -738,7 +738,7 b' def get__all__entries(obj):' | |||
|
738 | 738 | words = getattr(obj, '__all__') |
|
739 | 739 | except: |
|
740 | 740 | return [] |
|
741 | ||
|
741 | ||
|
742 | 742 | return [w for w in words if isinstance(w, str)] |
|
743 | 743 | |
|
744 | 744 | |
@@ -887,14 +887,14 b' def _safe_isinstance(obj, module, class_name):' | |||
|
887 | 887 | |
|
888 | 888 | def back_unicode_name_matches(text): |
|
889 | 889 | u"""Match unicode characters back to unicode name |
|
890 | ||
|
890 | ||
|
891 | 891 | This does ``☃`` -> ``\\snowman`` |
|
892 | 892 | |
|
893 | 893 | Note that snowman is not a valid python3 combining character but will be expanded. |
|
894 | 894 | Though it will not recombine back to the snowman character by the completion machinery. |
|
895 | 895 | |
|
896 | 896 | This will not either back-complete standard sequences like \\n, \\b ... |
|
897 | ||
|
897 | ||
|
898 | 898 | Used on Python 3 only. |
|
899 | 899 | """ |
|
900 | 900 | if len(text)<2: |
@@ -917,7 +917,7 b' def back_unicode_name_matches(text):' | |||
|
917 | 917 | |
|
918 | 918 | def back_latex_name_matches(text:str): |
|
919 | 919 | """Match latex characters back to unicode name |
|
920 | ||
|
920 | ||
|
921 | 921 | This does ``\\ℵ`` -> ``\\aleph`` |
|
922 | 922 | |
|
923 | 923 | Used on Python 3 only. |
@@ -991,7 +991,7 b' def _make_signature(completion)-> str:' | |||
|
991 | 991 | |
|
992 | 992 | class IPCompleter(Completer): |
|
993 | 993 | """Extension of the completer class with IPython-specific features""" |
|
994 | ||
|
994 | ||
|
995 | 995 | @observe('greedy') |
|
996 | 996 | def _greedy_changed(self, change): |
|
997 | 997 | """update the splitter and readline delims when greedy is changed""" |
@@ -999,36 +999,39 b' class IPCompleter(Completer):' | |||
|
999 | 999 | self.splitter.delims = GREEDY_DELIMS |
|
1000 | 1000 | else: |
|
1001 | 1001 | self.splitter.delims = DELIMS |
|
1002 | ||
|
1002 | ||
|
1003 | dict_keys_only = Bool(False, | |
|
1004 | help="""Whether to show dict key matches only""") | |
|
1005 | ||
|
1003 | 1006 | merge_completions = Bool(True, |
|
1004 | 1007 | help="""Whether to merge completion results into a single list |
|
1005 | ||
|
1008 | ||
|
1006 | 1009 | If False, only the completion results from the first non-empty |
|
1007 | 1010 | completer will be returned. |
|
1008 | 1011 | """ |
|
1009 | 1012 | ).tag(config=True) |
|
1010 | 1013 | omit__names = Enum((0,1,2), default_value=2, |
|
1011 | 1014 | help="""Instruct the completer to omit private method names |
|
1012 | ||
|
1015 | ||
|
1013 | 1016 | Specifically, when completing on ``object.<tab>``. |
|
1014 | ||
|
1017 | ||
|
1015 | 1018 | When 2 [default]: all names that start with '_' will be excluded. |
|
1016 | ||
|
1019 | ||
|
1017 | 1020 | When 1: all 'magic' names (``__foo__``) will be excluded. |
|
1018 | ||
|
1021 | ||
|
1019 | 1022 | When 0: nothing will be excluded. |
|
1020 | 1023 | """ |
|
1021 | 1024 | ).tag(config=True) |
|
1022 | 1025 | limit_to__all__ = Bool(False, |
|
1023 | 1026 | help=""" |
|
1024 | 1027 | DEPRECATED as of version 5.0. |
|
1025 | ||
|
1028 | ||
|
1026 | 1029 | Instruct the completer to use __all__ for the completion |
|
1027 | ||
|
1030 | ||
|
1028 | 1031 | Specifically, when completing on ``object.<tab>``. |
|
1029 | ||
|
1032 | ||
|
1030 | 1033 | When True: only those names in obj.__all__ will be included. |
|
1031 | ||
|
1034 | ||
|
1032 | 1035 | When False [default]: the __all__ attribute is ignored |
|
1033 | 1036 | """, |
|
1034 | 1037 | ).tag(config=True) |
@@ -1061,7 +1064,7 b' class IPCompleter(Completer):' | |||
|
1061 | 1064 | secondary optional dict for completions, to |
|
1062 | 1065 | handle cases (such as IPython embedded inside functions) where |
|
1063 | 1066 | both Python scopes are visible. |
|
1064 | ||
|
1067 | ||
|
1065 | 1068 | use_readline : bool, optional |
|
1066 | 1069 | DEPRECATED, ignored since IPython 6.0, will have no effects |
|
1067 | 1070 | """ |
@@ -1113,6 +1116,9 b' class IPCompleter(Completer):' | |||
|
1113 | 1116 | @property |
|
1114 | 1117 | def matchers(self): |
|
1115 | 1118 | """All active matcher routines for completion""" |
|
1119 | if self.dict_keys_only: | |
|
1120 | return [self.dict_key_matches] | |
|
1121 | ||
|
1116 | 1122 | if self.use_jedi: |
|
1117 | 1123 | return [ |
|
1118 | 1124 | self.file_matches, |
@@ -1621,7 +1627,7 b' class IPCompleter(Completer):' | |||
|
1621 | 1627 | closing_quote, token_offset, matches = match_dict_keys(keys, prefix, self.splitter.delims) |
|
1622 | 1628 | if not matches: |
|
1623 | 1629 | return matches |
|
1624 | ||
|
1630 | ||
|
1625 | 1631 | # get the cursor position of |
|
1626 | 1632 | # - the text being completed |
|
1627 | 1633 | # - the start of the key text |
@@ -1632,13 +1638,13 b' class IPCompleter(Completer):' | |||
|
1632 | 1638 | completion_start = key_start + token_offset |
|
1633 | 1639 | else: |
|
1634 | 1640 | key_start = completion_start = match.end() |
|
1635 | ||
|
1641 | ||
|
1636 | 1642 | # grab the leading prefix, to make sure all completions start with `text` |
|
1637 | 1643 | if text_start > key_start: |
|
1638 | 1644 | leading = '' |
|
1639 | 1645 | else: |
|
1640 | 1646 | leading = text[text_start:completion_start] |
|
1641 | ||
|
1647 | ||
|
1642 | 1648 | # the index of the `[` character |
|
1643 | 1649 | bracket_idx = match.end(1) |
|
1644 | 1650 | |
@@ -1657,18 +1663,18 b' class IPCompleter(Completer):' | |||
|
1657 | 1663 | # brackets were opened inside text, maybe close them |
|
1658 | 1664 | if not continuation.startswith(']'): |
|
1659 | 1665 | suf += ']' |
|
1660 | ||
|
1666 | ||
|
1661 | 1667 | return [leading + k + suf for k in matches] |
|
1662 | 1668 | |
|
1663 | 1669 | def unicode_name_matches(self, text): |
|
1664 | 1670 | u"""Match Latex-like syntax for unicode characters base |
|
1665 | 1671 | on the name of the character. |
|
1666 | ||
|
1672 | ||
|
1667 | 1673 | This does ``\\GREEK SMALL LETTER ETA`` -> ``η`` |
|
1668 | 1674 | |
|
1669 | 1675 | Works only on valid python 3 identifier, or on combining characters that |
|
1670 | 1676 | will combine to form a valid identifier. |
|
1671 | ||
|
1677 | ||
|
1672 | 1678 | Used on Python 3 only. |
|
1673 | 1679 | """ |
|
1674 | 1680 | slashpos = text.rfind('\\') |
@@ -1686,7 +1692,7 b' class IPCompleter(Completer):' | |||
|
1686 | 1692 | |
|
1687 | 1693 | def latex_matches(self, text): |
|
1688 | 1694 | u"""Match Latex syntax for unicode characters. |
|
1689 | ||
|
1695 | ||
|
1690 | 1696 | This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α`` |
|
1691 | 1697 | |
|
1692 | 1698 | Used on Python 3 only. |
@@ -1758,13 +1764,13 b' class IPCompleter(Completer):' | |||
|
1758 | 1764 | Returns an iterator over the possible completions |
|
1759 | 1765 | |
|
1760 | 1766 | .. warning:: Unstable |
|
1761 | ||
|
1767 | ||
|
1762 | 1768 | This function is unstable, API may change without warning. |
|
1763 | 1769 | It will also raise unless use in proper context manager. |
|
1764 | 1770 | |
|
1765 | 1771 | Parameters |
|
1766 | 1772 | ---------- |
|
1767 | ||
|
1773 | ||
|
1768 | 1774 | text:str |
|
1769 | 1775 | Full text of the current input, multi line string. |
|
1770 | 1776 | offset:int |
@@ -1793,7 +1799,7 b' class IPCompleter(Completer):' | |||
|
1793 | 1799 | and usual IPython completion. |
|
1794 | 1800 | |
|
1795 | 1801 | .. note:: |
|
1796 | ||
|
1802 | ||
|
1797 | 1803 | Completions are not completely deduplicated yet. If identical |
|
1798 | 1804 | completions are coming from different sources this function does not |
|
1799 | 1805 | ensure that each completion object will only be present once. |
@@ -1988,7 +1994,7 b' class IPCompleter(Completer):' | |||
|
1988 | 1994 | if name_text: |
|
1989 | 1995 | return name_text, name_matches[:MATCHES_LIMIT], \ |
|
1990 | 1996 | [meth.__qualname__]*min(len(name_matches), MATCHES_LIMIT), () |
|
1991 | ||
|
1997 | ||
|
1992 | 1998 | |
|
1993 | 1999 | # If no line buffer is given, assume the input text is all there was |
|
1994 | 2000 | if line_buffer is None: |
General Comments 0
You need to be logged in to leave comments.
Login now