← Back
Editing: completer.cpython-311.pyc
� �@�cP; � �F � d Z ddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZm Z ddl!m"Z" ddl#m$Z$ dd l%m&Z&m'Z' dd l(m)Z) ddl*m+Z+ ddl,m-Z- dd l.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7m8Z8mZ9m:Z:m;Z;m<Z< ddl=m>Z> ddl?Z?dZ@ ddlAZAdeAjB _C ddlDZAddlEZAdZFn # eG$ r dZFY nw xY wddgZHddgZIe jJ dk rdZKndZKdZL G d� deM� � ZN ejO deN�� � e+edPd!�� � � � ZPd"� ZQeKfd#�ZRd$eSd%eeSeTeSf fd&�ZUd$eSd'eTd(eSd%eSfd)�ZVd*� ZW G d+� d,� � ZX G d-� d.� � ZYeeY ZZd/eSd0eZd%eZfd1�Z[dd2�d/eSd0eZd3eTd%eZfd4�Z\e jJ dk rd5Z]nd6Z]d7Z^ G d8� d9e_� � Z` G d:� de>� � Zad;� Zb dQd<eeeSeceeeSecf f d=eSd>eSd?e eeSecf d%eeSedeeS f f d@�Zed/eSdAeddBedd%edfdC�Zfd/eSdDedd%eededf fdE�ZgdF� Zhd/eSd%eeSeeS f fdG�Zid/eSd%eeSeeS f fdH�Zjd%eSfdI�Zkd%eSfdJ�Zl G dK� dLe� � Zm G dM� dea� � ZndNeeededf d%eeS fdO�ZodS )Ru� Completion for IPython. This module started as fork of the rlcompleter module in the Python standard library. The original enhancements made to rlcompleter have been sent upstream and were accepted as of Python 2.3, This module now support a wide variety of completion mechanism both available for normal classic Python code, as well as completer for IPython specific Syntax like magics. Latex and Unicode completion ============================ IPython and compatible frontends not only can complete your code, but can help you to input a wide range of characters. In particular we allow you to insert a unicode character using the tab completion mechanism. Forward latex/unicode completion -------------------------------- Forward completion allows you to easily type a unicode character using its latex name, or unicode long description. To do so type a backslash follow by the relevant name and press tab: Using latex completion: .. code:: \alpha<tab> α or using unicode completion: .. code:: \GREEK SMALL LETTER ALPHA<tab> α Only valid Python identifiers will complete. Combining characters (like arrow or dots) are also available, unlike latex they need to be put after the their counterpart that is to say, ``F\\vec<tab>`` is correct, not ``\\vec<tab>F``. Some browsers are known to display combining characters incorrectly. Backward latex completion ------------------------- It is sometime challenging to know how to type a character, if you are using IPython, or any compatible frontend you can prepend backslash to the character and press ``<tab>`` to expand it to its latex form. .. code:: \α<tab> \alpha Both forward and backward completions can be deactivated by setting the ``Completer.backslash_combining_completions`` option to ``False``. Experimental ============ Starting with IPython 6.0, this module can make use of the Jedi library to generate completions both using static analysis of the code, and dynamically inspecting multiple namespaces. Jedi is an autocompletion and static analysis for Python. The APIs attached to this new mechanism is unstable and will raise unless use in an :any:`provisionalcompleter` context manager. You will find that the following are experimental: - :any:`provisionalcompleter` - :any:`IPCompleter.completions` - :any:`Completion` - :any:`rectify_completions` .. note:: better name for :any:`rectify_completions` ? We welcome any feedback on these new API, and we also encourage you to try this module in debug mode (start IPython with ``--Completer.debug=True``) in order to have extra logging information if :any:`jedi` is crashing, or if current IPython completer pending deprecations are returning results not yet handled by :any:`jedi` Using Jedi for tab completion allow snippets like the following to work without having to execute any code: >>> myvar = ['hello', 42] ... myvar[1].bi<tab> Tab completion will be able to infer that ``myvar[1]`` is a real number without executing any code unlike the previously available ``IPCompleter.greedy`` option. Be sure to update :any:`jedi` to the latest stable version or to try the current development version to get better completions. � N)�contextmanager)� import_module)�SimpleNamespace)�Iterable�Iterator�List�Tuple�Union�Any�Sequence�Dict� NamedTuple�Pattern�Optional)�TryNext)� ESC_MAGIC)� latex_symbols�reverse_latex_symbol)� InspectColors)�skip_doctest)�generics)�dir2�get_real_method)�ensure_dir_exists)� arg_split)�Bool�Enum�Intr �Unicode�default�observe)�ConfigurableTF)� iK )i i� � Completer�IPCompleter�win32� z ()[]{}?=\|;:'#*"^&i� c � � e Zd ZdZdS )�ProvisionalCompleterWarningz� Exception raise by an experimental feature in this module. Wrap code in :any:`provisionalcompleter` context manager if you are certain you want to use an unstable feature. N)�__name__� __module__�__qualname__�__doc__� � �8/usr/lib/python3/dist-packages/IPython/core/completer.pyr) r) � s � � � � � �� � �Dr/ r) �error��category�ignorec # � K � t j � � 5 t j | t �� � dV � ddd� � dS # 1 swxY w Y dS )a� This context manager has to be used in any place where unstable completer behavior and API may be called. >>> with provisionalcompleter(): ... completer.do_experimental_things() # works >>> completer.do_experimental_things() # raises. .. note:: Unstable By using this context manager you agree that the API in use may change without warning, and that you won't complain if they do so. You also understand that, if the API is not to your liking, you should report a bug to explain your use case upstream. We'll be happy to get your feedback, feature requests, and improvements on any of the unstable APIs! r2 N)�warnings�catch_warnings�filterwarningsr) )�actions r0 �provisionalcompleterr: � s� � � � �2 � � "� "� � ����1L�M�M�M�M� ����� � � � � � � � � � � ���� � � � � � s � A�A� Ac �n � | � d� � dz rdS | � d� � dz rdS dS )a Return whether a string has open quotes. This simply counts whether the number of quote characters of either type in the string is odd. Returns ------- If there is an open quote, the quote character is returned. Else, return False. �"� �'F)�count)�ss r0 �has_open_quotesrA � sA � � �w�w�s�|�|�a�� ��s� ������� � ��s��ur/ c � �� t | � � t �� � z r9t j dk rd| z dz S d� �fd�| D � � � � S | S )z.Escape a string to protect certain characters.r&