
    ^hZ                      % S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJrJr  SS	KJr  SS
K J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.  SSK/J0r0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7J8r8  SSK9J:r:  SSK;J<r<  SSK=J>r>  SSK?J@r@  SSKAJBrBJCrC  SSKDJErE  SSKFJGrG  SSKHJIrI  SSKJJKrKJLrLJMrMJ#rNJOrOJ(rPJ%rQJRrR  SSKSJTrT  SSKUrUSrV SSKWrWS\WR                  lY        SSKZrWSSK[rWSr\\*(       d  \E(       a%  \R                  S:  a  SSK J_r_  SSK`JaraJbrbJcrcJdrdJere  OSSK Jfrf  S r_\$rb\(ra\grc\&rd\fre\E(       a  SS K Jara  S!S"/rhS#S$/ri\R                  S%:X  a  S&rkOS'rkS(rlS)rm\g" 5       rn " S* S+\o5      rp\R                  " S,\pS-9  \<\SyS. j5       5       rrS/ rs\k4S0 jrtSzS1 jruS{S2 jrvS3 rw " S4 S55      rx\%S6\x4   ry " S7 S85      rz " S9 S:5      r{ " S; S<\a5      r|\@" SS=/S>9 " S? S@\|\a5      5       r} " SA SB\|5      r~\%\y\{4   r\-" SC\\z5      r\ " SD SE5      5       r\%\}\~4   r " SF SG\c5      r " SH SI\\c5      r\%\\4   rSJ\SK'    " SL SM\c5      r\%\\4   rSJ\SN'   S|SO jrS}SP jrS~SQ jrSSR jrSSS jrSSSTSU.     SSV jjrSSW jrSSX jrSY r\" \SZS[9r\!\z   rSS\ jrSS].SS^ jjr\R                  S%:X  a  S_rOS`rSar " Sb Sc\g5      r " Sd S#\T5      rSe r " Sf Sg\GR6                  5      rSh rSSi jr\\\Sj.r S         SSk jjrSSl jrSSm jrSn r\" 5       SSo j5       rSSp jr\" 5       SSq j5       rSSr jrSSs jrSSt jr\(\\4   r\GR^                  " Su5      r  S         SSv jjr " Sw S$\5      rSSx jrg! \] a    Sr\ GNf = f)u  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 :kbd:`Tab` to expand it to its latex form.

.. code::

    \α<tab>
    \alpha


Both forward and backward completions can be deactivated by setting the
:std:configtrait:`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 almost any code unlike the deprecated :any:`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.

Matchers
========

All completions routines are implemented using unified *Matchers* API.
The matchers API is provisional and subject to change without notice.

The built-in matchers include:

- :any:`IPCompleter.dict_key_matcher`:  dictionary key completions,
- :any:`IPCompleter.magic_matcher`: completions for magics,
- :any:`IPCompleter.unicode_name_matcher`,
  :any:`IPCompleter.fwd_unicode_matcher`
  and :any:`IPCompleter.latex_name_matcher`: see `Forward latex/unicode completion`_,
- :any:`back_unicode_name_matcher` and :any:`back_latex_name_matcher`: see `Backward latex completion`_,
- :any:`IPCompleter.file_matcher`: paths to files and directories,
- :any:`IPCompleter.python_func_kw_matcher` - function keywords,
- :any:`IPCompleter.python_matches` - globals and attributes (v1 API),
- ``IPCompleter.jedi_matcher`` - static analysis with Jedi,
- :any:`IPCompleter.custom_completer_matcher` - pluggable completer with a default
  implementation in :any:`InteractiveShell` which uses IPython hooks system
  (`complete_command`) with string dispatch (including regular expressions).
  Differently to other matchers, ``custom_completer_matcher`` will not suppress
  Jedi results to match behaviour in earlier IPython versions.

Custom matchers can be added by appending to ``IPCompleter.custom_matchers`` list.

Matcher API
-----------

Simplifying some details, the ``Matcher`` interface can described as

.. code-block::

    MatcherAPIv1 = Callable[[str], list[str]]
    MatcherAPIv2 = Callable[[CompletionContext], SimpleMatcherResult]

    Matcher = MatcherAPIv1 | MatcherAPIv2

The ``MatcherAPIv1`` reflects the matcher API as available prior to IPython 8.6.0
and remains supported as a simplest way for generating completions. This is also
currently the only API supported by the IPython hooks system `complete_command`.

To distinguish between matcher versions ``matcher_api_version`` attribute is used.
More precisely, the API allows to omit ``matcher_api_version`` for v1 Matchers,
and requires a literal ``2`` for v2 Matchers.

Once the API stabilises future versions may relax the requirement for specifying
``matcher_api_version`` by switching to :any:`functools.singledispatch`, therefore
please do not rely on the presence of ``matcher_api_version`` for any purposes.

Suppression of competing matchers
---------------------------------

By default results from all matchers are combined, in the order determined by
their priority. Matchers can request to suppress results from subsequent
matchers by setting ``suppress`` to ``True`` in the ``MatcherResult``.

When multiple matchers simultaneously request surpression, the results from of
the matcher with higher priority will be returned.

Sometimes it is desirable to suppress most but not all other matchers;
this can be achieved by adding a set of identifiers of matchers which
should not be suppressed to ``MatcherResult`` under ``do_not_suppress`` key.

The suppression behaviour can is user-configurable via
:std:configtrait:`IPCompleter.suppress_competing_matchers`.
    )annotationsN)literal_eval)defaultdict)contextmanager)	dataclass)cached_propertypartial)SimpleNamespace)IterableIteratorListTupleUnionAnySequenceDictOptionalTYPE_CHECKINGSetSizedTypeVarLiteral)guarded_evalEvaluationContext)TryNext)	ESC_MAGIC)latex_symbolsreverse_latex_symbol)InspectColors)skip_doctest)generics)sphinx_options)dir2get_real_method)GENERATING_DOCUMENTATION)ensure_dir_exists)	arg_split)BoolEnumIntr   Unicoder   r   observe)ConfigurableTF)      )cast)	TypedDictNotRequiredProtocol	TypeAlias	TypeGuard)Genericc                    U$ )z=Workaround for `TypeError: MatcherAPIv2() takes no arguments` )type_objs     P/home/james-whalen/.local/lib/python3.13/site-packages/IPython/core/completer.pyr0   r0   	  s    
    )r1   )    i# )i  i 	CompleterIPCompleterwin32 z ()[]{}?=\|;:'#*"^&i  z	<unknown>c                      \ rS rSrSrSrg)ProvisionalCompleterWarningi4  z
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.
r8   N)__name__
__module____qualname____firstlineno____doc____static_attributes__r8   r<   r;   rC   rC   4  s     	r<   rC   errorcategoryc              #     #    [         R                  " 5          [         R                  " U [        S9  Sv   SSS5        g! , (       d  f       g= f7f)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!
rK   N)warningscatch_warningsfilterwarningsrC   )actions    r;   provisionalcompleterrR   @  s2     2 
	 	 	"1LM 
#	"	"s   A?	A
A	Ac                l    U R                  S5      S-  (       a  gU R                  S5      S-  (       a  gg)zReturn 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    r;   has_open_quotesrY   ^  s-     	wws|a	
	r<   c                   ^ [        U 5      [        T5      -  (       a7  [        R                  S:X  a  SU -   S-   $ SR                  U4S jU  5       5      $ U $ )z.Escape a string to protect certain characters.r@   rT    c              3  <   >#    U  H  oT;   a  S U-   OUv   M     g7f\Nr8   ).0cprotectabless     r;   	<genexpr>#protect_filename.<locals>.<genexpr>y  s     M1a\(9D1Hq@1s   )setsysplatformjoin)rX   ra   s    `r;   protect_filenamerh   s  sH    
1vL!!<<7"7S= 77M1MMMr<   c                    SnSnU nU R                  S5      (       a?  Sn[        U 5      S-
  n[        R                  R	                  U 5      nU(       a  USU*  nOUnX1U4$ )ap  Expand ``~``-style usernames in strings.

This is similar to :func:`os.path.expanduser`, but it computes and returns
extra information that will be useful if the input was being used in
computing completions, and you wish to return the completions with the
original '~' instead of its expanded value.

Parameters
----------
path : str
    String to be expanded.  If no ~ is present, the output is the same as the
    input.

Returns
-------
newpath : str
    Result of ~ expansion in the input path.
tilde_expand : bool
    Whether any expansion was performed or not.
tilde_val : str
    The value that ~ was replaced with.
Fr[   ~T   N)
startswithlenospath
expanduser)ro   tilde_expand	tilde_valnewpathrests        r;   expand_userru   ~  sh    0 LIGs4y{''$$T*$II)++r<   c                8    U(       a  U R                  US5      $ U $ )z8Does the opposite of expand_user, with its outputs.
    rj   )replace)ro   rq   rr   s      r;   compress_userrx     s     ||Is++r<   c                >   Su  pU R                  S5      (       a  SnOU R                  S5      (       a  SnU R                  S5      (       a  SnU R                  S5      (       a  S	U SS
 ;  a  U SS
 n SnO&U R                  S	5      (       a  S	U SS
 ;  a  U SS
 n SnXU4$ )zkey for sorting completions

This does several things:

- Demote any completions starting with underscores to the end
- Insert any %magic and %%cellmagic completions in the alphabetical order
  by their name
)r   r   __rU   _rk   =z%%%N)rl   endswith)wordprio1prio2s      r;   completions_sorting_keyr     s     LEt			}}Std12h8DE			d12h8DEr<   c                  $    \ rS rSrSrS rS rSrg)_FakeJediCompletioni  z
This is a workaround to communicate to the UI that Jedi has crashed and to
report a bug. Will be used only id :any:`IPCompleter.debug` is set to true.

Added in IPython 6.0 so should likely be removed for 7.0

c                `    Xl         Xl        SU l        Xl        SU l        SU l        SU l        g )Ncrashedr[   fake)namecompletetypename_with_symbols	signature_origintext)selfr   s     r;   __init___FakeJediCompletion.__init__  s.    		!%	r<   c                    g)Nz)<Fake completion object jedi has crashed>r8   r   s    r;   __repr___FakeJediCompletion.__repr__  s    :r<   )r   r   r   r   r   r   r   N)rD   rE   rF   rG   rH   r   r   rI   r8   r<   r;   r   r     s    ;r<   r   zjedi.api.Completionc                  ^    \ rS rSrSr/ SQrSSSS.         SS jjrS rSS	 jrS
 r	Sr
g)
Completioni  a/  
Completion object used and returned by IPython completers.

.. warning::

    Unstable

    This function is unstable, API may change without warning.
    It will also raise unless use in proper context manager.

This act as a middle ground :any:`Completion` object between the
:any:`jedi.api.classes.Completion` object and the Prompt Toolkit completion
object. While Jedi need a lot of information about evaluator and how the
code should be ran/inspected, PromptToolkit (and other frontend) mostly
need user facing information.

- Which range should be replaced replaced by what.
- Some metadata (like completion type), or meta information to displayed to
  the use user.

For debugging purpose we can also store the origin of the completion (``jedi``,
``IPython.python_matches``, ``IPython.magics_matches``...).
startendr   r   r   r   Nr[   r   r   r   c                   [         R                  " S[        SS9  Xl        X l        X0l        X@l        X`l        XPl        g )Nz~``Completion`` is a provisional API (as of IPython 6.0). It may change without warnings. Use in corresponding context manager.rU   rL   
stacklevel)	rN   warnrC   r   r   r   r   r   r   )r   r   r   r   r   r   r   s          r;   r   Completion.__init__  s=     	4 1	
 
		"r<   c                    SU R                   < SU R                  < SU R                  < SU R                  =(       d    S< SU R                  =(       d    S< S3$ )Nz<Completion start=z end=z text= type=?z, signature=z,>)r   r   r   r   r   r   s    r;   r   Completion.__repr__  s>    TXXtyy$))2Bs2BDNNDYVYDY[ 	[r<   c                    U R                   UR                   :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ )a%  
Equality and hash do not hash the type (as some completer may not be
able to infer the type), but are use to (partially) de-duplicate
completion.

Completely de-duplicating completion is a bit tricker that just
comparing as it depends on surrounding text, which Completions are not
aware of.
)r   r   r   )r   others     r;   __eq__Completion.__eq__!  sC     zzU[[( $HH		!$II#	$r<   c                Z    [        U R                  U R                  U R                  45      $ N)hashr   r   r   r   s    r;   __hash__Completion.__hash__/  s     TZZ499566r<   )r   r   r   r   r   r   )
r   intr   r   r   strr   Optional[str]returnNone)r   bool)rD   rE   rF   rG   rH   	__slots__r   r   r   r   rI   r8   r<   r;   r   r     s_    0 II #  	  
2[$7r<   r   c                  8    \ rS rSrSrSS/rSS.S
S jjrS rS	rg)SimpleCompletioni3  a  Completion item to be included in the dictionary returned by new-style Matcher (API v2).

.. warning::

    Provisional

    This class is used to describe the currently supported attributes of
    simple completion items, and any additional implementation details
    should not be relied on. Additional attributes may be included in
    future versions, and meaning of text disambiguated from the current
    dual meaning of "text to insert" and "text to used as a label".
r   r   Nr   c                   Xl         X l        g r   r   r   )r   r   r   s      r;   r   SimpleCompletion.__init__C  s    		r<   c                @    SU R                   < SU R                  < S3$ )Nz<SimpleCompletion text=r   >r   r   s    r;   r   SimpleCompletion.__repr__G  s    (VDII=JJr<   r   )r   r   r   r   )	rD   rE   rF   rG   rH   r   r   r   rI   r8   r<   r;   r   r   3  s!      I;? Kr<   r   c                  B    \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   Srg)_MatcherResultBaseiK  zFDefinition of dictionary to be returned by new-style Matcher (API v2).zNotRequired[str]matched_fragmentz"NotRequired[Union[bool, Set[str]]]suppresszNotRequired[Set[str]]do_not_suppresszNotRequired[bool]orderedr8   NrD   rE   rF   rG   rH   __annotations__rI   r8   r<   r;   r   r   K  s%    P '& 10 +* r<   r   dict)show_inherited_membersexclude_inherited_fromc                  $    \ rS rSr% SrS\S'   Srg)SimpleMatcherResulti]  z'Result of new-style completion matcher.z7Sequence[SimpleCompletion] | Iterator[SimpleCompletion]completionsr8   Nr   r8   r<   r;   r   r   ]  s    1 IHr<   r   c                  $    \ rS rSr% SrS\S'   Srg)_JediMatcherResultih  z@Matching result returned by Jedi (will be processed differently)Iterator[_JediCompletionLike]r   r8   Nr   r8   r<   r;   r   r   h  s    J /.r<   r   AnyCompletionc                  t    \ rS rSr% SrS\S'   S\S'   S\S'   S\S'   S	\S
'   \SS j5       r\SS j5       rSr	g)CompletionContextis  zMCompletion context provided as an argument to matchers in the Matcher API v2.r   token	full_textr   cursor_positioncursor_linezOptional[int]limitc                4    U R                   S U R                   $ r   )line_with_cursorr   r   s    r;   text_until_cursor#CompletionContext.text_until_cursor  s    $$%;t';';<<r<   c                R    U R                   R                  S5      U R                     $ )N
)r   splitr   r   s    r;   r   "CompletionContext.line_with_cursor  s"    ~~##D)$*:*:;;r<   r8   Nr   r   )
rD   rE   rF   rG   rH   r   r   r   r   rI   r8   r<   r;   r   r   s  sQ    W J N   = = < <r<   r   c                  *    \ rS rSr% SS jrS\S'   Srg)_MatcherAPIv1Basei  r   c                    gzCall signature.Nr8   r   r   s     r;   __call___MatcherAPIv1Base.__call__      r<   rF   r8   Nr   r   r   	List[str])rD   rE   rF   rG   r   r   rI   r8   r<   r;   r   r     s    
 r<   r   c                  *    \ rS rSr% S\S'   SS jrSrg)_MatcherAPIv1Totali  zOptional[Literal[1]]matcher_api_versionc                    gr   r8   r   s     r;   r   _MatcherAPIv1Total.__call__  r   r<   r8   Nr   )rD   rE   rF   rG   r   r   rI   r8   r<   r;   r   r     s    --r<   r   r4   MatcherAPIv1c                  <    \ rS rSr% SrSrS\S'   SS jrS\S'   S	rg
)MatcherAPIv2i  z#Protocol describing Matcher API v2.rU   z
Literal[2]r   c                    gr   r8   )r   contexts     r;   r   MatcherAPIv2.__call__  r   r<   r   rF   r8   N)r   r   r   MatcherResult)	rD   rE   rF   rG   rH   r   r   r   rI   r8   r<   r;   r   r     s    - '('
 r<   r   Matcherc                "    [        U 5      nUS:H  $ )Nrk   _get_matcher_api_versionmatcherapi_versions     r;   _is_matcher_v1r         *73K!r<   c                "    [        U 5      nUS:H  $ )NrU   r   r   s     r;   _is_matcher_v2r    r   r<   c                    [        U S5      $ )%Determines whether objects is sizable__len__hasattrvalues    r;   _is_sizabler	    s    5)$$r<   c                    [        U S5      $ )r  __next__r  r  s    r;   _is_iteratorr    s    5*%%r<   c                   U S   n[        U5      (       a  [        U5      S:g  $ [        U5      (       a?   Un[        U5      n[	        [
        [           [        R                  " U/U5      5      U S'   g[        S5      e! [         a     gf = f)z-Check if any result includes any completions.r   r   TFzCCompletions returned by matcher need to be an Iterator or a Sizable)r	  rm   r  nextr0   r   r   	itertoolschainStopIteration
ValueError)resultr   old_iteratorfirsts       r;   has_any_completionsr    s    'K;;1$$K  		&L&E$()*6%F=!  M   		s   =A> >
B
Brk   )priority
identifierr   c                    ^ ^^ SUUU 4S jjnU$ )a  Adds attributes describing the matcher.

Parameters
----------
priority : Optional[float]
    The priority of the matcher, determines the order of execution of matchers.
    Higher priority means that the matcher will be executed first. Defaults to 0.
identifier : Optional[str]
    identifier of the matcher allowing users to modify the behaviour via traitlets,
    and also used to for debugging (will be passed as ``origin`` with the completions).

    Defaults to matcher function's ``__qualname__`` (for example,
    ``IPCompleter.file_matcher`` for the built-in matched defined
    as a ``file_matcher`` method of the ``IPCompleter`` class).
api_version: Optional[int]
    version of the Matcher API used by this matcher.
    Currently supported values are 1 and 2.
    Defaults to 1.
c                   > T=(       d    SU l         T=(       d    U R                  U l        TU l        [        (       a.  TS:X  a  [        [        U 5      n U $ TS:X  a  [        [        U 5      n U $ )Nr   rk   rU   )matcher_priorityrF   matcher_identifierr   r   r0   r   r   )funcr   r  r  s    r;   wrapper#completion_matcher.<locals>.wrapper  se     (A","A0A0A#. =aL$/  !L$/r<   )r  r   r8   )r  r  r   r  s   ``` r;   completion_matcherr     s    4	 	 Nr<   c                    [        U SS5      $ )Nr  r   getattrr   s    r;   _get_matcher_priorityr%    s    7.22r<   c                0    [        U SU R                  5      $ )Nr  )r#  rF   r$  s    r;   _get_matcher_idr'    s    70'2F2FGGr<   c                    [        U SS5      $ )Nr   rk   r"  r$  s    r;   r   r     s    71155r<   rU   r   c              #  ,  #    [        U5      nU(       d  g[        S U 5       5      n[        S U 5       5      n[        5       nU HI  nXUR                   UR
                  -   XR                  U -   nXd;  d  M4  Uv   UR                  U5        MK     g7f)a  
Deduplicate a set of completions.

.. warning::

    Unstable

    This function is unstable, API may change without warning.

Parameters
----------
text : str
    text that should be completed.
completions : Iterator[Completion]
    iterator over the completions to deduplicate

Yields
------
`Completions` objects
Completions coming from multiple sources, may be different but end up having
the same effect when applied to ``text``. If this is the case, this will
consider completions as equal and only emit the first encountered.
Not folded in `completions()` yet for debugging purpose, and to detect when
the IPython completer does return things that Jedi does not, but should be
at some point.
Nc              3  8   #    U  H  oR                   v   M     g 7fr   r   r_   r`   s     r;   rb   +_deduplicate_completions.<locals>.<genexpr>G  s     1[GG[   c              3  8   #    U  H  oR                   v   M     g 7fr   r   r-  s     r;   rb   r.  H  s     -A%%r/  )listminmaxrd   r   r   r   add)r   r   	new_startnew_endseenr`   new_texts          r;   _deduplicate_completionsr:  (  s     6 {#K1[11I---G5D!''*QVV3d556IIGHHX	 s   A4B:B)_debugc          
   #  |  #    [         R                  " S[        SS9  [        U5      nU(       d  gS U 5       nS U 5       n[	        U5      n[        U5      n[        5       n[        5       nU H  n	XU	R                   U	R                  -   X	R                  U -   n
U	R                  S:X  a  UR                  U
5        O!U	R                  S:X  a  UR                  U
5        [        XVXR                  U	R                  U	R                  S	9v   M     UR                  U5      nU(       a  U(       a  [!        S
U5        ggg7f)aq  
Rectify a set of completions to all have the same ``start`` and ``end``

.. warning::

    Unstable

    This function is unstable, API may change without warning.
    It will also raise unless use in proper context manager.

Parameters
----------
text : str
    text that should be completed.
completions : Iterator[Completion]
    iterator over the completions to rectify
_debug : bool
    Log failed completion

Notes
-----
:any:`jedi.api.classes.Completion` s returned by Jedi may not have the same start and end, though
the Jupyter Protocol requires them to behave like so. This will readjust
the completion to have the same ``start`` and ``end`` by padding both
extremities with surrounding text.

During stabilisation should support a ``_debug`` option to log which
completion are return by the IPython completer and not found in Jedi in
order to make upstream bug report.
z`rectify_completions` is a provisional API (as of IPython 6.0). It may change without warnings. Use in corresponding context manager.rU   r   Nc              3  8   #    U  H  oR                   v   M     g 7fr   r,  r-  s     r;   rb   &rectify_completions.<locals>.<genexpr>y  s     +{!gg{r/  c              3  8   #    U  H  oR                   v   M     g 7fr   r1  r-  s     r;   rb   r>  z  s     ';aEE;r/  jedizIPCompleter.python_matchesr   z#IPython.python matches have extras:)rN   r   rC   r2  r3  r4  rd   r   r   r   r   r5  r   r   r   
differenceprint)r   r   r;  startsendsr6  r7  	seen_jediseen_python_matchesr`   r9  diffs               r;   rectify_completionsrH  R  s    > MM 9 71F
 {#K+{+F';'DFI$iGI%!''*QVV3d556II99MM(#YY66##H-XFFAIIabalalmm  )))4D3T: ts   D:D<z 	
`!@#$^&*()=+[{]}|;'",<>?z 	
`!@#$^&*()=+[{]}\|;:'",<>?z =
c                  l    \ rS rSrSr\rSrSrS	S jr	\
S 5       r\R                  S 5       rS	S jrSrg)
CompletionSplitteri  a7  An object to split an input line in a manner similar to readline.

By having our own implementation, we can expose readline-like completion in
a uniform manner to all frontends.  This object only needs to be given the
line of text to be split and the cursor position on said line, and it
returns the 'word' to be completed on at the cursor after splitting the
entire line.

What characters are used as splitting delimiters can be controlled by
setting the ``delims`` attribute (this is a property that internally
automatically builds the necessary regular expression)Nc                :    Uc  [         R                  OUnXl        g r   )rJ  _delimsdelims)r   rM  s     r;   r   CompletionSplitter.__init__  s    /5~#++6r<   c                    U R                   $ )z*Return the string of delimiter characters.)rL  r   s    r;   rM  CompletionSplitter.delims  s     ||r<   c                    SSR                  S U 5       5      -   S-   n[        R                  " U5      U l        Xl        X l        g)z&Set the delimiters for line splitting.[r[   c              3  ,   #    U  H
  nS U-   v   M     g7fr]   r8   r-  s     r;   rb   ,CompletionSplitter.delims.<locals>.<genexpr>  s     5fT1Wf   ]N)rg   recompile	_delim_rerL  _delim_expr)r   rM  exprs      r;   rM  rP    s=     RWW5f555;D)r<   c                R    Uc  UOUSU nU R                   R                  U5      S   $ )zBSplit a line of text with a cursor at the given position.
        Nr}   )rY  r   )r   line
cursor_posls       r;   
split_lineCompletionSplitter.split_line  s1     &DD*,=~~##A&r**r<   )rZ  rY  rL  rM  r   )rD   rE   rF   rG   rH   DELIMSrL  rZ  rY  r   propertyrM  setterr`  rI   r8   r<   r;   rJ  rJ    sR    
>  G
 K I   ]]   +r<   rJ  c                  ^  ^  \ rS rSr\" SSS9R                  SS9r\" SSS	S
9R                  SS9r\" \	SS
9R                  SS9r
\" SSS
9R                  SS9r\" SSS
9R                  SS9r\" SSS9R                  SS9r\" SSS9R                  SS9rSU 4S jjrS rS rS rS rSrU =r$ )r>   i  Fal  Activate greedy completion.

        .. deprecated:: 8.8
            Use :std:configtrait:`Completer.evaluation` and :std:configtrait:`Completer.auto_close_dict_keys` instead.

        When enabled in IPython 8.8 or newer, changes configuration as follows:

        - ``Completer.evaluation = 'unsafe'``
        - ``Completer.auto_close_dict_keys = True``
        helpTconfig)	forbiddenminimallimitedunsafe	dangerousrl  a  Policy for code evaluation under completion.

        Successive options allow to enable more eager evaluation for better
        completion suggestions, including for nested dictionaries, nested lists,
        or even results of function calls.
        Setting ``unsafe`` or higher can lead to evaluation of arbitrary user
        code on :kbd:`Tab` with potentially unwanted or dangerous side effects.

        Allowed values are:

        - ``forbidden``: no evaluation of code is permitted,
        - ``minimal``: evaluation of literals and access to built-in namespace;
          no item/attribute evaluationm no access to locals/globals,
          no evaluation of any operations or comparisons.
        - ``limited``: access to all namespaces, evaluation of hard-coded methods
          (for example: :any:`dict.keys`, :any:`object.__getattr__`,
          :any:`object.__getitem__`) on allow-listed objects (for example:
          :any:`dict`, :any:`list`, :any:`tuple`, ``pandas.Series``),
        - ``unsafe``: evaluation of all methods and function calls but not of
          syntax with side-effects like `del x`,
        - ``dangerous``: completely arbitrary evaluation.
        default_valuerg  zYExperimental: Use Jedi to generate autocompletions. Default to True if jedi is installed.i  zExperimental: restrict time (in milliseconds) during which Jedi can compute types.
        Set to 0 to stop computing types. Non-zero value lower than 100ms may hurt
        performance by preventing jedi to build its cache.
        zaEnable debug for the Completer. Mostly print extra information for experimental jedi integration.zEnable unicode completions, e.g. \alpha<tab> . Includes completion of latex commands, unicode names, and expanding unicode characters back to latex commands.a.  
        Enable auto-closing dictionary keys.

        When enabled string keys will be suffixed with a final quote
        (matching the opening quote), tuple keys will also receive a
        separating comma if needed, and keys which are final will
        receive a closing bracket (``]``).
        c                   > Uc  SU l         OSU l         Xl        Uc  0 U l        OX l        / U l        [        [
        U ]  " S0 UD6  g)a  Create a new completer for the command line.

Completer(namespace=ns, global_namespace=ns2) -> completer instance.

If unspecified, the default namespace where completions are performed
is __main__ (technically, __main__.__dict__). Namespaces should be
given as dictionaries.

An optional second namespace can be given.  This allows the completer
to handle cases where both the local and global scopes need to be
distinguished.
NTFr8   )use_main_ns	namespaceglobal_namespacecustom_matcherssuperr>   r   )r   rs  rt  kwargs	__class__s       r;   r   Completer.__init__  sP    " #D$D&N #$&D!$4!!i'1&1r<   c                    U R                   (       a  [        R                  U l        US:X  a3  SU;   a  U R	                  U5      U l        OU R                  U5      U l         U R
                  U   $ ! [         a     gf = f)zReturn the next possible completion for 'text'.

This is called successively with state == 0, 1, 2, ... until it
returns None.  The completion should begin with 'text'.

r   .N)rr  __main____dict__rs  attr_matchesmatchesglobal_matches
IndexError)r   r   states      r;   r   Completer.complete5  sr     %..DNA:d{#006#2248	<<&& 		s   !A0 0
A=<A=c                r   / nUR                   n[        U5      n[        R                  [        R
                  R                  5       [        U R                  R                  5       5      [        U R                  R                  5       5      4 H'  nU H  nUSU U:X  d  M  US:w  d  M  U" U5        M      M)     [        R                  " S5      n[        U R                  R                  5       5      [        U R                  R                  5       5      4 H  nU VVs0 s HO  nUR                  U5      (       d  M  SR                  UR                  S5       Vs/ s H  oS   PM	     sn5      U_MQ     n	nnU	R                  5        H   nUSU U:X  d  M  US:w  d  M  U" X   5        M"     M     U$ s  snf s  snnf )zCompute matches when text is a simple name.

Return a list of all keywords, built-in functions and names currently
defined in self.namespace or self.global_namespace that match.

N__builtins__z[^_]+(_[^_]+)+?\Zr{   r   )appendrm   keywordkwlistbuiltin_modr}  keysr2  rs  rt  rW  rX  matchrg   r   )
r   r   r  match_appendnlstr   snake_case_resub	shorteneds
             r;   r  Completer.global_matchesI  sy    ~~INN  %%'$$&'&&++-.	
C 8t#(> & 
 

#78,,./d6K6K6P6P6R1STC  D &&t, DDJJsO<OSa&O<=tC  
 "(8t#(> 1 ) U  =s   F39F3F.%F3.F3c                   [         R                  " SU R                  5      nU(       d  / $ UR                  SS5      u  p4U R	                  U5      nU[
        L a  / $ U R                  (       a  [        US5      (       a  [        U5      nO[        U5      n [        R                  " XV5      n[        U5      n[!        U5      n[#        U5      n	[$        R&                  [$        R(                  1n
Sn/ nU	 H  nUR*                  U
;   a  M  UR*                  [$        R,                  :X  a&  U(       a  UR/                  UR0                  5        SnMY  UR*                  [$        R2                  :X  a6  UR0                  S:X  a&  U(       d  UR/                  UR0                  5        SnM    O   SR5                  [#        U5      5      nU Vs/ s H  oS	U U:X  d  M  U< SU< 3PM     sn$ ! [         a     GNC[         a    e [         a     GNYf = fs  snf )
a  Compute matches when text contains a dot.

Assuming the text is of the form NAME.NAME....[NAME], and is
evaluatable in self.namespace or self.global_namespace, it will be
evaluated and its attributes (as revealed by dir()) are used as
possible completions.  (For class instances, class members are
also considered.)

WARNING: this can still invoke arbitrary C code, if an object
with a __getattr__ hook is evaluated.

z(.+)\.(\w*)$rk   rU   __all__TFr{  r[   N)rW  r  line_buffergroup_evaluate_expr	not_foundlimit_to__all__r  get__all__entriesr#   r!   complete_objectr   AssertionError	Exceptionrm   _parse_tokensreversedtokenize	ENDMARKERNEWLINEr   NAMEr  stringOPrg   )r   r   m2r[  attrr:   wordsr  tokens
rev_tokens	skip_over	name_turnpartsr   prefix_after_spacews                   r;   r~  Completer.attr_matchesi  s    XXot'7'78IXXa^
!!$')IGC$;$;%c*EIE	,,S8E I t$f%
'')9)9:		EzzY&zzX]]*yU\\*!	x{{*u||s/B9U\\* 	     WWXe_5;@R5abqETM1-q15RRG  	 	 		> Ss$   G! HH!
H.HHc           	     0   [         nSnU(       dM  U(       aF   [        U[        U R                  U R                  U R
                  S95      nSnU(       d	  U(       a  MF  U$ ! [         a,  nU R                  (       a  [        SU5        USS  n S nANCS nAff = f)NF)globalslocals
evaluationTzEvaluation exceptionrk   )	r  r   r   rt  rs  r  r  debugrB  )r   r[  r:   donees        r;   r  Completer._evaluate_expr  s    4 "% $ 5 5#~~#'??  44& 
   ::0!4
 ABx s   5A 
B)"BB)ru  rt  r  rs  rr  )NN)rD   rE   rF   rG   r(   taggreedyr)   r  JEDI_INSTALLEDuse_jedir*   jedi_compute_type_timeoutr  backslash_combining_completionsauto_close_dict_keysr   r   r  r~  r  rI   __classcell__rx  s   @r;   r>   r>     s&   	 
cc  B2 
cc3 6 .<==@SS=M  !$#! SS	  uGH s$s' 

 '+4:'; <?3d3;K $
  
 
cc 2B(@ASF r<   c                     [        U S5      nU Vs/ s H  n[        U[        5      (       d  M  UPM     sn$ !   / s $ = fs  snf )z,returns the strings in the __all__ attributer  )r#  
isinstancer   )r:   r  r  s      r;   r  r    sA    Y' 3u!
1c 2Au33	3s   8 AA>c                      \ rS rSrSrSr\R                  " 5       r\R                  " 5       r	\R                  " 5       r
Srg)_DictKeyStatei  a  Represent state of the key match in context of other possible matches.

- given `d1 = {'a': 1}` completion on `d1['<tab>` will yield `{'a': END_OF_ITEM}` as there is no tuple.
- given `d2 = {('a', 'b'): 1}`: `d2['a', '<tab>` will yield `{'b': END_OF_TUPLE}` as there is no tuple members to add beyond `'b'`.
- given `d3 = {('a', 'b'): 1}`: `d3['<tab>` will yield `{'a': IN_TUPLE}` as `'a'` can be added.
- given `d4 = {'a': 1, ('a', 'b'): 2}`: `d4['<tab>` will yield `{'a': END_OF_ITEM & END_OF_TUPLE}`
r   r8   N)rD   rE   rF   rG   rH   BASELINEenumautoEND_OF_ITEMEND_OF_TUPLEIN_TUPLErI   r8   r<   r;   r  r    s/     H))+K99;Lyy{Hr<   r  c                   / n[         R                  " [        U R                  5       5      R                  5      n  UR                  [        U5      5        M  ! [         R                   a    Us $ [         a    Us $ f = f)z'Parse tokens even if there is an error.)	r  generate_tokensiter
splitlinesr  r  r  
TokenErrorr  )r`   r  token_generators      r;   r  r    so    F..tALLN/C/L/LMO
	MM$/0  "" 	M 	M	s   A A>0A>=A>c                   U S   R                  5       (       a  g[        U 5      n[        U5      n[        R                  [        R
                  1nSnU H  nUR                  U;   a  M  Uc.  UR                  [        R                  :X  a  UR                  nMD    gUR                  [        R                  :X  a6  UR                  S:X  a    U$ UR                  S;   a  UR                  U-   nM  M    g   U$ )zMatch any valid Python numeric literal in a prefix of dictionary keys.

References:
- https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals
- https://docs.python.org/3/library/tokenize.html
r}   N,>   +-)
isspacer  r  r  r  r  r   NUMBERr  r  )prefixr  r  r  numberr   s         r;    _match_number_in_dict_key_prefixr    s     bz 6"F&!J##X%5%56IF::">zzX__, ::$||s"
 M	 ||z). * ! " Mr<   )0b0o0xc           	       ^^^ U(       a  UOSm[        T Vs/ s H  n[        U[        5      (       + PM     sn5      m[        [        [
        [        [        4mUUU4S jn[        S 5      nU  H  n[        U[        5      (       aR  U" U5      (       aC  UT   nXg==   [        U5      TS-   :X  a  [        R                  O[        R                  -  ss'   Mh  Mj  TS:  a  Mr  [        UT5      (       d  M  Xd==   [        R                  -  ss'   M     UR                  5       nU(       d2  SSUR                  5        VV	s0 s H  u  pI[!        U5      U	_M     sn	n4$ ["        R$                  " SU5      n
SnU
(       a!  U
R'                  5       nX-   n [)        U5      nO[-        U5      nUc  SS0 4$ UnS
nSnSSR/                  S U 5       5      -   S-   n["        R$                  " UU["        R0                  5      nUc   eUR3                  5       nUR'                  5       n0 nU GH  n[        U[
        [        45      (       aX  U(       d  M(  [        U5      n[        U[
        5      (       a.  US	S R5                  5       nU[6        ;   a  [6        U   nU" U5      nOU(       a  M  Un UR9                  U5      (       d  M   U[        U5      S	 n[        U[        5      (       a  [!        US-   5      O[!        US-   5      nUSURA                  S5      -   S nUS:X  a  URC                  SS5      nU< U< 3nUU   UU'   GM     UUU4$ s  snf s  sn	nf ! [*         a    SS0 4s $ f = f! [:        [<        [>        4 a  n S	nAGM`  S	nAff = f)a!  Used by dict_key_matches, matching the prefix to a list of keys

Parameters
----------
keys
    list of keys in dictionary currently being completed.
prefix
    Part of the text already typed by the user. E.g. `mydict[b'fo`
delims
    String of delimiters to consider when finding the current key.
extra_prefix : optional
    Part of the text already typed in multi-key index cases. E.g. for
    `mydict['foo', "bar", 'b`, this would be `('foo', 'bar')`.

Returns
-------
A tuple of three elements: ``quote``, ``token_start``, ``matched``, with
``quote`` being the quote that need to be used to close current string.
``token_start`` the position where the replacement should start occurring,
``matches`` a dictionary of replacement/completion keys on keys and values
    indicating whether the state.
r8   c                   > [        U 5      T::  a  gU  H  n[        UT5      (       a  M    g   [        U T5       H#  u  pX:w  d  M  [        U[        5      (       a  M#    g   g)NFT)rm   r  zipslice)keykptprefix_tupleprefix_tuple_sizetext_serializable_typess      r;   filter_prefix_tuple,match_dict_keys.<locals>.filter_prefix_tuple;  s\    s8((Aa!899  l+EAwz"e44 , r<   c                 "    [         R                  $ r   )r  r  r8   r<   r;   <lambda>!match_dict_keys.<locals>.<lambda>L  s
    M22r<   rk   r   r[   z(?:"|')FNTz[^c              3  ,   #    U  H
  nS U-   v   M     g7fr]   r8   r-  s     r;   rb   "match_dict_keys.<locals>.<genexpr>  s     6v!TAXvrU  z]*$rU   rT      "rV   z\")"sumr  r  r   bytesr   floatr   tuplerm   r  r  r  r  r  itemsreprrW  searchr  r   r  r  rg   UNICODEr   lower_INT_FORMATSrl   AttributeError	TypeErrorUnicodeErrorindexrw   ) r  r  rM  extra_prefixr  r  filtered_key_is_finalkey_fragmentfiltered_keysvquote_matchis_user_prefix_numericquotevalid_prefix
prefix_strnumber_matchpatterntoken_matchtoken_starttoken_prefixmatchedr  str_keyint_base
int_formatr  remrem_reprr  r  r  r  s                                 @@@r;   match_dict_keysr    s   8 $0<RL "	
 " 1e$$!	
  #E3u=" 	23  
 a"1%% !23%31v!2Q!66 "..&//3 & " !455%(M,E,EE(' * *..0M1.C.I.I.KL.KdatAwz.KLLL))J/K"!!#~	%l3J 8?  q"9!
!%RWW6v666>G))GVRZZ8K"""##%K$$&L(*G cC<(()#hG#s##%bq>//1|+!-h!7J(oG &G	%%j11 2 c*o'(&0c&:&:4c	?S4Z@PAs 33B7C<  ''U3H '1.s3M N +w&&	
f M  	q"9	^ 	<8 		s/   M>M
M %M&M#"M#&NNc           	         U R                  S5      nU[        U5      ::  d2   SR                  [        U5      [        [        U5      5      5      5       e[	        S USU  5       5      U-   $ )a  
Convert the (line,column) position of the cursor in text to an offset in a
string.

Parameters
----------
text : str
    The text in which to calculate the cursor offset
line : int
    Line of the cursor; 0-indexed
column : int
    Column of the cursor 0-indexed

Returns
-------
Position of the cursor in ``text``, 0-indexed.

See Also
--------
position_to_cursor : reciprocal of this function

r   z{} <= {}c              3  >   #    U  H  n[        U5      S -   v   M     g7f)rk   N)rm   )r_   r_  s     r;   rb   %cursor_to_position.<locals>.<genexpr>  s     0<as1vz<s   N)r   rm   formatr   r  )r   r]  columnliness       r;   cursor_to_positionr    s^    . JJtE3u:Lz00TCE
OLL05$<00699r<   c                    SUs=::  a  [        U 5      ::  d  O   SU< S[        U 5      < 35       eU SU nUR                  S5      nUR                  S5      n[        US   5      nXE4$ )a  
Convert the position of the cursor in text (0 indexed) to a line
number(0-indexed) and a column number (0-indexed) pair

Position should be a valid position in ``text``.

Parameters
----------
text : str
    The text in which to calculate the cursor offset
offset : int
    Position of the cursor in ``text``, 0-indexed.

Returns
-------
(line, column) : (int, int)
    Line of the cursor; 0-indexed, column of the cursor 0-indexed

See Also
--------
cursor_to_position : reciprocal of this function

r   z0 <= z <= Nr   r}   )rm   r   rW   )r   offsetbeforeblinesr]  cols         r;   position_to_cursorr!    se    2 ##d)#L#d)&LL#'6]F\\$F<<D
fRj/C9r<   c                    U[         R                  ;   a5  [         R                  U   nU/UQ H  n[        XE5      nM     [        X5      $ g)z@Checks if obj is an instance of module.class_name if loaded
    N)re   modulesr#  r  )r:   module
class_nameattrsmr  s         r;   _safe_isinstancer(    sJ     KK(%(D A )#!!	 r<   c                H    [        U R                  5      u  p[        USUSS9$ )zyMatch Unicode characters back to Unicode name

Same as :any:`back_unicode_name_matches`, but adopted to new Matcher API.
unicodeTr   fragmentsuppress_if_matches)back_unicode_name_matchesr    _convert_matcher_v1_result_to_v2r   r,  r  s      r;   back_unicode_name_matcherr1    s-     2'2K2KLH+i( r<   c                    [        U 5      S:  a  gU S   nUS:w  a  gU S   nU[        R                  ;   d  US;   a  g [        R                  " U5      nSU-   SU-   44$ ! [
         a     gf = f)u  Match Unicode characters back to Unicode name

This does  ``☃`` -> ``\snowman``

Note that snowman is not a valid python3 combining character but will be expanded.
Though it will not recombine back to the snowman character by the completion machinery.

This will not either back-complete standard sequences like \n, \b ...

.. deprecated:: 8.6
    You can use :meth:`back_unicode_name_matcher` instead.

Returns
=======

Return a tuple with two elements:

- The Unicode character that was matched (preceded with a backslash), or
    empty string,
- a sequence (of 1), name for the match Unicode character, preceded by
    backslash, or empty if no match.
rU   r[   r8   r  r^   r}   rT   rV   )rm   r  ascii_lettersunicodedatar   KeyError)r   maybe_slashcharunics       r;   r.  r.  	  s    . 4y{r(Kd8D v###ty'8%Dy$t)%% s    A 
A,+A,c                H    [        U R                  5      u  p[        USUSS9$ )zuMatch latex characters back to unicode name

Same as :any:`back_latex_name_matches`, but adopted to new Matcher API.
latexTr+  )back_latex_name_matchesr   r/  r0  s      r;   back_latex_name_matcherr>  3  s-     00I0IJH+gd r<   c                    [        U 5      S:  a  gU S   nUS:w  a  gU S   nU[        R                  ;   d  US;   a  g [        U   nSU-   U/4$ ! [         a     gf = f)u   Match latex characters back to unicode name

This does ``\ℵ`` -> ``\aleph``

.. deprecated:: 8.6
    You can use :meth:`back_latex_name_matcher` instead.
rU   r3  r  r^   r}   r4  )rm   r  r5  r   r7  )r   r8  r9  r<  s       r;   r=  r=  ?  s     4y{r(Kd 8D v###ty'8$T*Dy%   s   A 
AAc                l    U R                   nUR                  S5      (       d  [        SU-  5      eUSS $ )z
Get parameter name and value from Jedi Private API

Jedi does not expose a simple way to get `param=value` from its API.

Parameters
----------
parameter
    Jedi's function `Param`

Returns
-------
A string like 'a', 'b=1', '*args', '**kwargs'

zparam zWJedi function parameter description have change format.Expected "param ...", found %r".   N)descriptionrl   r  )	parameterrB  s     r;   _formatparamchildrenrD  \  sI      ''K!!(++ <>IJ K 	Kqr?r<   c                R   [        U S5      (       aO  U R                  5       nU(       d  gU R                  5       S   nSUR                  5       R                  SSS9S   -   $ SSR	                  S	 U R                  5        5        Vs/ s H  nU(       d  M  UPM     sn5      -  $ s  snf )
a&  
Make the signature from a jedi completion

Parameters
----------
completion : jedi.Completion
    object does not complete a function type

Returns
-------
a string consisting of the function signature, with the parenthesis but
without the function name. example:
`(a, *args, b=1, **kwargs)`

get_signaturesz(?)r   (rk   )maxsplitz(%s), c              3  h   #    U  H(  nUR                  5         H  n[        U5      v   M     M*     g 7fr   )defined_namesrD  )r_   r   ps      r;   rb   "_make_signature.<locals>.<genexpr>  s7      *NSni3<3J3J3La +?q*A*A3L +BSns   02)r  rF  	to_stringr   rg   )
completion
signaturesc0fs       r;   _make_signaturerS  r  s    $ z+,,..0
&&(+2<<>''a'8;;;499 *NS]SlSlSn *N T *NAQR   *N T U U U Ts   B$
B$
a  (?x)
(  # match dict-referring - or any get item object - expression
    .+
)
\[   # open bracket
\s*  # and optional whitespace
# Capture any number of serializable objects (e.g. "a", "b", 'c')
# and slices
((?:(?:
    (?: # closed string
        [uUbB]?  # string prefix (r not handled)
        (?:
            '(?:[^']|(?<!\\)\\')*'
        |
            "(?:[^"]|(?<!\\)\\")*"
        )
    )
    |
        # capture integers and slices
        (?:[-+]?\d+)?(?::(?:[-+]?\d+)?){0,2}
    |
        # integer in bin/hex/oct notation
        0[bBxXoO]_?(?:\w|\d)+
    )
    \s*,\s*
)*)
((?:
    (?: # unclosed string
        [uUbB]?  # string prefix (r not handled)
        (?:
            '(?:[^']|(?<!\\)\\')*
            |
            "(?:[^"]|(?<!\\)\\")*
        )
    )
    |
        # unfinished integer
        (?:[-+]?\d+)
    |
        # integer in bin/hex/oct notation
        0[bBxXoO]_?(?:\w|\d)+
    )
)?
$
c                    U  Vs/ s H  n[        XAS9PM     snU(       a  U (       a  SOSOSS.nUb  X%S'   [        [        U5      $ s  snf )zUtility to help with transitionr   TFr   r   r   )r   r0   r   )r  r   r,  r-  r  r  s         r;   r/  r/    sU     NUUWE(e?WU4GWT%UF %-!"#V,, Vs   Ac            
        ^  \ rS rSrSr\" S5      S 5       r\" SSS9r\	" \" SS	9\
" \" S
SS	95      /S
SS9R                  SS9r\" SSS9R                  SS9r\" \" 5       SS9R                  SS9r\" SSSS9R                  SS9r\" SSS9R                  SS9r\" SSS9R                  SS9r\" SSS9R                  SS9r\" S5      S 5       r SFU 4S jjr\SGS j5       rSHS jrSIS jrSIS jr\" 5       SJS j5       rSHS jr\" 5       SJS  j5       r SIS! jr!\" 5       SJS" j5       r"SHS# jr#\" 5       SJS$ j5       r$SHS% jr%\" S&S'9SKS( j5       r&        SLS) jr'\(" S*S+9SMS, j5       r)S- r*S. r+\" 5       SJS/ j5       r,S0 r-\.SNS1 j5       r/\" 5       SJS2 j5       r0SHS3 jr1\" 5       SOS4 j5       r2\.SPS5 j5       r3\" 5       SOS6 j5       r4SQS7 jr5\" 5       S8 5       r6S9 r7SRS: jr8SSS; jr9STSUS< jjr:      SVS= jr;S
S
S
S>. SWS? jjr<\.    SXS@ j5       r=\.SYSA j5       r>\" 5       SOSB j5       r?SQSC jr@\SZSD j5       rASErBU =rC$ )[r?   i  z?Extension of the completer class with IPython-specific featuresr  c                    US   (       a$  SU l         SU l        [        U R                  l        gSU l         SU l        [
        U R                  l        g)z>update the splitter and readline delims when greedy is changednewrm  Trl  FN)r  r  GREEDY_DELIMSsplitterrM  rb  r   changes     r;   _greedy_changedIPCompleter._greedy_changed  sA     %=&DO(,D%#0DMM 'DO(-D%#)DMM r<   Fz
        Whether to show dict key matches only.

        (disables all matchers except for `IPCompleter.dict_key_matcher`).
        rf  T)
allow_noneNag  
        Whether to suppress completions from other *Matchers*.

        When set to ``None`` (default) the matchers will attempt to auto-detect
        whether suppression of other matchers is desirable. For example, at
        the beginning of a line followed by `%` we expect a magic completion
        to be the only applicable option, and after ``my_dict['`` we usually
        expect a completion with an existing dictionary key.

        If you want to disable this heuristic and see completions from all matchers,
        set ``IPCompleter.suppress_competing_matchers = False``.
        To disable the heuristic for specific matchers provide a dictionary mapping:
        ``IPCompleter.suppress_competing_matchers = {'IPCompleter.dict_key_matcher': False}``.

        Set ``IPCompleter.suppress_competing_matchers = True`` to limit
        completions to the set of matchers with the highest priority;
        this is equivalent to ``IPCompleter.merge_completions`` and
        can be beneficial for performance, but will sometimes omit relevant
        candidates from matchers further down the priority list.
        ro  rh  a6  Whether to merge completion results into a single list

        If False, only the completion results from the first non-empty
        completer will be returned.

        As of version 8.6.0, setting the value to ``False`` is an alias for:
        ``IPCompleter.suppress_competing_matchers = True.``.
        z{List of matchers to disable.

        The list should contain matcher identifiers (see :any:`completion_matcher`).
        )r   rk   rU   rU   a1  Instruct the completer to omit private method names

        Specifically, when completing on ``object.<tab>``.

        When 2 [default]: all names that start with '_' will be excluded.

        When 1: all 'magic' names (``__foo__``) will be excluded.

        When 0: nothing will be excluded.
        a3  
        DEPRECATED as of version 5.0.

        Instruct the completer to use __all__ for the completion

        Specifically, when completing on ``object.<tab>``.

        When True: only those names in obj.__all__ will be included.

        When False [default]: the __all__ attribute is ignored
        zEIf True, emit profiling data for completion subsystem using cProfile.z.completion_profileszBTemplate for path at which to output profile data for completions.r  c                :    [         R                  " S[        5        g )Nz`IPython.core.IPCompleter.limit_to__all__` configuration value has been deprecated since IPython 5.0, will be made to have no effects and then removed in future version of IPython.)rN   r   UserWarningr[  s     r;   _limit_to_all_changed!IPCompleter._limit_to_all_changed?  s     H 	r<   c                  > [         U l        [        5       U l        [        TU ]  " SUUUS.UD6  / U l        Xl        [        R                  " S5      U l
        [        R                  U l        [        R                  R                  SS5      nUS;   U l        [         R"                  S:X  a  U R$                  U l        OU R(                  U l        [        R                  " S5      U l        [        R                  " S5      U l        U R.                  U R0                  /U l        S	U l        S	U l        U R8                  U R:                  [<        [>        U R@                  /U l!        U RD                  (       d7  U RB                   H'  nU RF                  RI                  [K        U5      5        M)     U RL                  (       d  S
U l'        g	g	)aj  IPCompleter() -> completer

Return a completer object.

Parameters
----------
shell
    a pointer to the ipython shell itself.  This is needed
    because this completer knows about magic functions, and those can
    only be accessed via the ipython instance.
namespace : dict, optional
    an optional dict where completions are performed.
global_namespace : dict, optional
    secondary optional dict for completions, to
    handle cases (such as IPython embedded inside functions) where
    both Python scopes are visible.
config : Config
    traitlet's config object
**kwargs
    passed to super class unmodified.
)rs  rt  ri  z([^\\] )TERMxterm)dumbemacsr@   z^[\w|\s.]+\(([^)]*)\).*z[\s|\[]*(\w+)(?:\s*=\s*.*)NTr8   )(r   magic_escaperJ  rZ  rv  r   r  shellrW  rX  space_name_reglobrn   environgetdumb_terminalre   rf   _clean_glob_win32
clean_glob_clean_globdocstring_sig_redocstring_kwd_remagic_config_matchermagic_color_matchermagic_arg_matcherscustom_completers_unicode_nameslatex_name_matcherunicode_name_matcherr>  r1  fwd_unicode_matcher_backslash_combining_matchersr  disable_matchersr  r'  merge_completionssuppress_competing_matchers)	r   rj  rs  rt  ri  rw  termr   rx  s	           r;   r   IPCompleter.__init__F  s   2 &*, 	 	
-	
 		
 
ZZ4II	 zz~~fW-!%55 <<7""44DO"..DO !#

+E F "

+H I
 %%$$#
 "& # ##%%#%$$.
* 33==%%,,_W-EF > %%/3D, &r<   c                    U R                   (       a  U R                  /$ U R                  (       ab  / U R                  QU R                  QU R
                  QU R                  PU R                  PU R                  PU R                  PU R                  P$ / U R                  QU R                  QU R
                  QU R                  PU R                  PU R                  PU R                  PU R                  PU R                  P$ )z*All active matcher routines for completion)dict_keys_onlydict_key_matcherr  ru  r}  rw  custom_completer_matchermagic_matcher_jedi_matcherfile_matcherpython_matchespython_func_kw_matcherr   s    r;   matchersIPCompleter.matchers  s?    ))**==	%%	33	 ((	 --		
 ""	 ""	 %%	 !!	 	%%33 (( --	
 %% "" ## !! ++ r<   c                z   UR                  S5      S   n[        5          U R                  U[        U5      5       Vs/ s HC  nU(       a-  U R                  (       a  SR                  X#R                  /5      OUR                  PME     snsSSS5        $ s  snf ! , (       d  f       O= fU R                  U5      S   $ )zA
Wrapper around the completion methods for the benefit of emacs.
r{  r   Nrk   )
rpartitionrR   r   rm   r  rg   r   r   )r   r   r  r`   s       r;   all_completionsIPCompleter.all_completions  s     %a(!#!--dCI>@> 39T]]CHHfff-.PQPVPVV>@ $#@ $# }}T"1%%s   BA
BBB
B&c                *    U R                  SU-  5      $ )N%s*)rl  r   s     r;   rr  IPCompleter._clean_glob  s    yy&&r<   c                v    U R                  SU-  5       Vs/ s H  nUR                  SS5      PM     sn$ s  snf )Nr  r^   /)rl  rw   )r   r   rR  s      r;   rp  IPCompleter._clean_glob_win32  s?    54<020A 		$s#02 	2 2s   6c                L    U R                  UR                  5      n[        USS9$ )z<Same as :any:`file_matches`, but adopted to new Matcher API.ro   r   )file_matchesr   r/  r   r   r  s      r;   r  IPCompleter.file_matcher  s'     ##GMM2 0fEEr<   c           	     Z   UR                  S5      (       a  USS nSnOSnU R                  n[        U5      nSU;   d  SU;   a  UnO [        U5      S   nU(       d  U[        U5      :w  a  SnXpO!S	n[        R                  R                  U5      nUS:X  a-  U R                  S
5       Vs/ s H  o[        U5      -   PM     sn$ [        R                  S:X  a  U R                  U5      n	O!U R                  UR                  SS5      5      n	U(       a/  [!        U5      n
U	 Vs/ s H  nUW-   [        XS 5      -   PM     nnOXU(       a3  [        R                  S:X  a  U	OU	 Vs/ s H  n[        X5      PM     snnOU	 Vs/ s H  nU[        U5      -   PM     nnU Vs/ s H.  n[        R                  R#                  U5      (       a  US-   OUPM0     sn$ ! [         a#    U(       a  UR                  U5      S   n GN/ s $ [         a    Sn GNf = fs  snf s  snf s  snf s  snf s  snf )a}  Match filenames, expanding ~USER type strings.

Most of the seemingly convoluted logic in this completer is an
attempt to handle filenames with spaces in them.  And yet it's not
quite perfect, because Python's readline doesn't expose all of the
GNU readline details needed for this to be done correctly.

For a filename with a space in it, the printed completions will be
only the parts after what's already been typed (instead of the
full completions, as is normally done).  I don't think with the
current (as of Python 2.3) Python readline it's possible to do
better.

.. deprecated:: 8.6
    You can use :meth:`file_matcher` instead.
!rk   Nr[   rG  rR  r}   TF*r@   r^   r  )rl   r   rY   r'   r  r   r  rh   rn   ro   rp   rl  re   rf   rq  rw   rm   isdir)r   r   text_prefixr   open_quoteslsplithas_protectablestext0rR  m0
len_lsplitr  xs                r;   r  IPCompleter.file_matches  s7   , ??38DKK 22%&78##s.?'?F"#45b9 v)9&)AA#$$77%%d+D2:?Cyy~N~!"21"55~NN <<7"&BdB!78B VJACEACA #U*'+78AC  EG  !$ 7"?ABr!%a5rB  9;<8:1 '+A./8:  < ;BB'Qq))#q0'BB]  .44[A"EFI  OE C< Cs<   G +H"H#H H#5H(%H>HHHc                    UR                   nU R                  U5      n[        USS9n[        U5      S:  =(       a    US   S:H  nU=(       a    [	        US   5      US'   U$ )zMatch magics.magicr   r   r~   r   r   )r   magic_matchesr/  rm   r   )r   r   r   r  r  is_magic_prefixs         r;   r  IPCompleter.magic_matcher/  sa     }}$$T*1'Hd)a-:DGsN,Lf]6K1Lzr<   c                  ^^ U R                   R                  R                  5       nUS   nUS   nU R                  nXU-   nUR	                  U5      nUR                  U5      mU R                  T5      mU(       d  UU4S jnOU4S jnU V	s/ s H  o" U	5      (       d  M  Xi-   PM     n
n	UR	                  U5      (       d%  X V	s/ s H  o" U	5      (       d  M  XY-   PM     sn	-  n
U
$ s  sn	f s  sn	f )zRMatch magics.

.. deprecated:: 8.6
    You can use :meth:`magic_matcher` instead.
r]  cellc                >   > U R                  T5      =(       a    U T;  $ )z[
Filter magics, in particular remove magics that match
a name present in global namespace.
rl   )r  	bare_textr  s    r;   r  *IPCompleter.magic_matches.<locals>.matchesV  s%    
 )))4 5n47r<   c                &   > U R                  T5      $ r   r  )r  r  s    r;   r  r  ^  s    ''	22r<   )rj  magics_managerlsmagicri  rl   lstripr  )r   r   lsmline_magicscell_magicsprepre2explicit_magicr  r'  compr  r  s              @@r;   r  IPCompleter.magic_matches9  s     jj''//1&k&kw- KK$	,,Y773 "-;A
;t$$[?[GAJece[??D	 <?s   C(!C(C-C-c                L    U R                  UR                  5      n[        USS9$ )z3Match class names and attributes for %config magic.paramr   )magic_config_matchesr   r/  r  s      r;   ru   IPCompleter.magic_config_matcherg  s'     ++G,D,DE/gFFr<   c                @   UR                  5       R                  5       n[        U5      S:  Ga  US   S:X  d
  US   S:X  Ga  [        [	        U R
                  R                   Vs/ s H%  nUR                  R                  SS9(       d  M#  UPM'     sn5      S S9nU Vs/ s H  o3R                  R                  PM     nn[        U5      S:X  a  U$ US   R                  S	5      nUS   nU Vs/ s H  nUR                  U5      (       d  M  UPM     nnUS   R                  S	5      S:  a  U$ [        U5      S:X  a  US   U:X  a  XER                  U5         R                  n	U	R                  5       n
[        R                  " [        R                   " S
[        R"                  5      SU
5      n
U
R                  5       R%                  5        Vs/ s H2  nUR                  US   5      (       d  M  UR                  S5      S   PM4     sn$ / $ s  snf s  snf s  snf s  snf )zMatch class names and attributes for %config magic.

.. deprecated:: 8.6
    You can use :meth:`magic_config_matcher` instead.
r   ri  z%configTrh  c                .    U R                   R                  $ r   )rx  rD   r  s    r;   r  2IPCompleter.magic_config_matches.<locals>.<lambda>z  s    Q[[5I5Ir<   r  rk   r{  z^--r[   r|   )stripr   rm   sortedrd   rj  configurablesrx  class_traitsrD   rl   findr  class_get_helprW  r  rX  	MULTILINEr  )r   r   textsr`   classes
classnamesclassname_texts	classnameclassname_matchesclsrg  r  s               r;   r   IPCompleter.magic_config_matchesn  s    

""$u:>uQx83uQx97LSdjj.F.F "%.F&'kk&>&>d&>&K $%.F "% &+IKG :ABA;;//JB 5zQ!! $AhnnS1O'*I-7 !?Z%&\\)%< #$Z !? Qx}}S!A%((&'1,-a0I=..y9:DD))+vvbjj>DI%)ZZ\%<%<%>8%>T OOE!H5 ,C+%>8 8 	7"% C!?8s*   $"H
HH.HHH/Hc                L    U R                  UR                  5      n[        USS9$ )z&Match color schemes for %colors magic.r  r   )magic_color_matchesr   r/  r  s      r;   rv  IPCompleter.magic_color_matcher  s'     **7+C+CD/gFFr<   c                F   UR                  5       nUR                  S5      (       a  UR                  S5        [        U5      S:X  aU  US   S:X  d	  US   S:X  aC  US   n[        R
                  " 5        Vs/ s H  nUR                  U5      (       d  M  UPM     sn$ / $ s  snf )zqMatch color schemes for %colors magic.

.. deprecated:: 8.6
    You can use :meth:`magic_color_matcher` instead.
rA   r[   rU   r   colorsz%colorsrk   )r   r   r  rm   r   r  rl   )r   r   r  r  colors        r;   r  IPCompleter.magic_color_matches  s     

== LLu:?aH 4aI8M1XF(5(:(:(< 3(<u((0 (< 3 3	3s   5BBzIPCompleter.jedi_matcher)r  c                j    U R                  UR                  UR                  UR                  S9nUSS.$ )N)cursor_columnr   r   FrU  )_jedi_matchesr   r   r   r  s      r;   r  IPCompleter._jedi_matcher  sD    $$!11++"" % 
 #
 	
r<   c                   U R                   /nU R                  b  UR                  U R                  5        S n[        X2U5      nU(       am  X6S-
     nUS:X  a`  U R                  S:X  a  S nOLU R                  S:X  a  S nO8U R                  S:X  a  S	 nO$[        S
R                  U R                  5      5      e[        R                  " USU U5      nSn	 Sn
 [        S UR                  5       R                  R                   5       5      n[        UR                  5      S:  =(       a    UR                  S   S;   n
U
(       + n	U	(       d  ['        / 5      $  [)        XXR+                  XS-   S95      $ ! [         a     NAf = f! [          a(  nU R"                  (       a  [%        SUS5         SnANkSnAff = f! [          aC  nU R"                  (       a  ['        [-        SU-  5      /5      s SnA$ ['        / 5      s SnA$ SnAff = f)a  
Return a list of :any:`jedi.api.Completion`s object from a ``text`` and
cursor position.

Parameters
----------
cursor_column : int
    column position of the cursor in ``text``, 0-indexed.
cursor_line : int
    line position of the cursor in ``text``, 0-indexed
text : str
    text to complete

Notes
-----
If ``IPCompleter.debug`` is ``True`` may return a :any:`_FakeJediCompletion`
object containing a string with the Jedi debug information attached.

.. deprecated:: 8.6
    You can use :meth:`_jedi_matcher` instead.
Nc                    U $ r   r8   r  s    r;   r  +IPCompleter._jedi_matches.<locals>.<lambda>  s    Qr<   rk   r{  rU   c                B    U R                   R                  S5      (       + $ )Nr{   )r   rl   r`   s    r;   r  r    s    QVV5F5Fs5K1Kr<   c                    U R                   R                  S5      =(       a    U R                   R                  S5      (       + $ )Nrz   )r   rl   r   r  s    r;   r  r    s.    aff6G6G6M6gRSRXRXRaRabfRg1hr<   r   c                    U $ r   r8   r  s    r;   r  r    s    r<   z'Don't understand self.omit__names == {}TFc              3  L   #    U  H  n[        US 5      (       d  M  Uv   M     g7f)r  Nr  r-  s     r;   rb   ,IPCompleter._jedi_matches.<locals>.<genexpr>  s      "r.Z^efgip^q11.Zs   $	$>   rT   rV   z5Error detecting if completing a non-finished string :|)r  r]  zJOops Jedi has crashed, please report a bug with the following:
"""
%s
s""")rs  rt  r  r  omit__namesr  r  r@  Interpreterr  _get_module	tree_nodechildrenrm   r  r  r  r  rB  r  filterr   r   )r   r  r   r   
namespacescompletion_filterr  r  interpretertry_jedicompleting_stringfirst_childr  s                r;   r  IPCompleter._jedi_matches  s   0 nn%
  ,d334&#D}Eax.Ccz##q((K%%%*(h%%%*(2%$%N%U%UVZVfVf%ghh&&tGV}jA	W %f""rk.E.E.G.Q.Q.Z.Z"rr %((9(9$:Q$>$e;CTCTUVCW[eCe! -,H 8O	 +-A-Akl]l-A-mnn' !   	WzzMqRUV	W  	 zz+k "  Bx	 sf   F 4E3 8F F8 3
F =F ?F  F 
F5F00F58
H(H *H0
H :H Hrk   r)  c                   SU;   a]   U R                  U5      nUR                  S5      (       a3  U R                  (       a"  U R                  S:X  a  S nOS n[        X25      nU$ U R                  U5      nU$ ! [         a    / n U$ f = f)z'Match attributes or global python namesr{  rk   c                4    [         R                  " SU 5      S L $ )Nz.*\.__.*?__)rW  r  txts    r;   r  ,IPCompleter.python_matches.<locals>.<lambda>	  s    $&HH^C$@D$Hr<   c                V    [         R                  " SX R                  S5      S  5      S L $ )Nz\._.*?r{  )rW  r  rindexr  s    r;   r  r  	  s$    $&HHYs::c?;K7L$MQU$Ur<   )r~  r   r  r  	NameErrorr  )r   r   r  no__names       r;   r  IPCompleter.python_matches	  s     $;++D1==%%$*:*:''1,%I%V$X7G  ))$/G   s   AA7 7BBc                &   Uc  / $ UR                  5       R                  5       S   nU R                  R                  U5      nUc  / $ UR	                  5       S   R                  S5      n/ nU H   nX@R                  R                  U5      -  nM"     U$ )a  Parse the first line of docstring for call signature.

        Docstring should be of the form 'min(iterable[, key=func])
'.
        It can also parse cython docstring of the form
        'Minuit.migrad(self, int ncall=10000, resume=True, int nsplit=1)'.
        r   r  )r  r  rs  r  groupsr   rt  findall)r   docr]  sigretrX   s         r;   !_default_arguments_from_docstring-IPCompleter._default_arguments_from_docstring&	  s     ;I zz|&&(+ ##**40;Ijjl1o##C(A((0033C  
r<   c                   ^ Un/ n[         R                  " U5      (       a  O[         R                  " U5      (       d  [         R                  " U5      (       dx  [         R                  " U5      (       a@  X0R                  [        USS5      5      -  n[        USS5      =(       d    [        USS5      nO[        US5      (       a  UR                  nX0R                  [        USS5      5      -  n[         R                  R                  [         R                  R                  4m [         R                  " U5      nUR                  U4S jUR                  R                  5        5       5        [#        [%        U5      5      $ ! [          a     N f = f)zWReturn the list of default arguments of obj if it is callable,
or empty list otherwise.rH   r[   r   N__new__r   c              3  P   >#    U  H  u  pUR                   T;   d  M  Uv   M     g 7fr   )kind)r_   r  r  _keepss      r;   rb   1IPCompleter._default_arguments.<locals>.<genexpr>[	  s(      )%;TQvv' q%;s   &	&)inspect	isbuiltin
isfunctionismethodisclassr
  r#  r  r   	ParameterKEYWORD_ONLYPOSITIONAL_OR_KEYWORDr   extend
parametersr  r  r2  rd   )r   r:   call_objr	  r  r  s        @r;   _default_argumentsIPCompleter._default_arguments@	  sX    S!!$$S))W-=-=c-B-Bs## ==#CB79 9 $CT: 5sIt4  j))<<559b13 	3 ##00##99;	##C(CJJ )S^^%9%9%; ) )
 CH~  		s   #A	F   
FFc                L    U R                  UR                  5      n[        USS9$ )z:Match named parameters (kwargs) of the last open function.r  r   )python_func_kw_matchesr   r/  r  s      r;   r  "IPCompleter.python_func_kw_matcherb	  s%     --gmm</gFFr<   c                @   SU;   a  / $ U R                   nUR                  U R                  5      n[        U5      nSnU H%  nUS:X  a  US-  nM  US:X  d  M  US-  nUS:  d  M%    O   / $ / n[        R                  " S5      R                  n  UR                  [        U5      5        U" US   5      (       d  UR                  5         O[        U5      S:X  d  O MO  [        5       n	Sn
[        X3SS	 5       H=  u  pkUS:X  a  U
S-  n
OUS:X  a  U
S-  n
U
S:w  a  M$  US
:w  a  M,  U	R!                  U5        M?     / n SR#                  US	S	S2   5      nU R%                  ['        UU R(                  5      5      n[        U5      U	-
   H/  nUR+                  U5      (       d  M  UR                  SU-  5        M1     U$ ! [         a@    [        R                  " S[        R                  [        R
                  -  5      =o l          GNf = f! [         a     GM8  f = f!    U$ = f)zMatch named parameters (kwargs) of the last open function.

.. deprecated:: 8.6
    You can use :meth:`python_func_kw_matcher` instead.
r{  z
                '.*?(?<!\\)' |    # single quoted strings or
                ".*?(?<!\\)" |    # double quoted strings or
                \w+          |    # identifier
                \S                # other characters
                r   )rk   rG  z\w+$r}   Nr|   z%s=)_IPCompleter__funcParamsRegexr  rW  rX  VERBOSEDOTALLr  r   r  r  r  r  popr  rd   r  r5  rg   r  evalrs  rl   )r   r   regexpr  
iterTokensopenParr   idsisIdusedNamedArgs	par_level
next_token
argMatchescallableObj	namedArgsnamedArgs                   r;   r   "IPCompleter.python_func_kw_matchesh	  s-    $;I,,V  6 67f%
wE|1#1Q;   Izz'"((

4
+,CG}}GGIuJ'3. /  	!$VABZ!8E|Q	#Q	A~S e$ "9 

	((3tt9-K//[48NN1D EI  	N]:&&t,,%%eXo6 ; I  	-.0jj :
 ZZ"))+/- -F+	-D ! >	s=   F9 :H 	H :A!H H 9AHH
HHHc                   [        U S5      nUb  U" 5       $ [        U [        5      (       d  [        U SS5      (       a   [	        U R                  5       5      $ [        U SSSS5      (       a$   [	        U R                  R                  5       5      $ [        U SS5      (       d  [        U SS	5      (       a  U R                  R                  =(       d    / $ / $ ! [         a    / s $ f = f! [         a    / s $ f = f)
N_ipython_key_completions_pandas	DataFramecoreindexing_LocIndexernumpyndarrayvoid)
r$   r  r   r(  r2  r  r  r:   dtypenames)r:   methods     r;   	_get_keysIPCompleter._get_keys	  s     !&AB8O c4  $4S(K$P$PCHHJ'' c8VZOOCGGLLN++ c7I66c7F3399??(b(	  	
  	s#   C -"C' C$#C$'C65C6c                N    U R                  UR                  5      n[        USSS9$ )z7Match string keys in a dictionary, after e.g. ``foo[``.zdict keyTr   r-  )dict_key_matchesr   r/  r  s      r;   r  IPCompleter.dict_key_matcher	  s,     ''6/*$
 	
r<   c           
     (   U R                   R                  5       R                  S5      (       a  / $ [        R	                  U R                   5      nUc  / $ UR                  5       u  p4nU R                  U5      nU[        L a  / $ U R                  U5      nU(       d  U$ [        U[        U R                  U R                  U R                  SS95      n[        XuU R                  R                   US9u  pnU(       d  / $ [#        U R                   5      [#        U5      -
  nU(       a  UR%                  S5      nX-   nOUR'                  5       =pX:  a  SnOXU nSnSnU R(                  [#        U R                   5      S R                  5       nUR+                  U	5      (       a  U[#        U	5      S nOSnUR                  5       n[-        U[.        5      nUR+                  S5      (       + =(       a    U R0                  nUR+                  S	5      (       + =(       a    U=(       a    U R0                  nU=(       a    U R0                  nU(       d$  U(       d  U	(       a  U Vs/ s H  nUU-   PM
     sn$ / n[2        R4                  [2        R6                  -  nUR9                  5        Hh  u  nnUU-   nU(       a  U	(       a  UU	-  nUU:X  a   UU;   a  U(       a  US-  nU[2        R:                  :X  a  U(       a  US
-  nUR=                  U5        Mj     U$ s  snf )zMatch string keys in a dictionary, after e.g. ``foo[``.

.. deprecated:: 8.6
    You can use :meth:`dict_key_matcher` instead.
rV  NT)r  r  r  in_subscript)r  r.   r[   Fr  rI  )r   r  r   DICT_MATCHER_REGEXr  r  r  r  rC  r   r   rt  rs  r  r  rZ  rM  rm   r   r   r  rl   r  r   r  r  r  r  r  r  r  )r   r   r  r[  prior_tuple_keys
key_prefixr:   r  tuple_prefixclosing_quotetoken_offsetr  
text_start	key_startcompletion_startleadingcan_close_quotecan_close_bracketcontinuationhas_known_tuple_handlingcan_close_tuple_itemr  resultsend_of_tuple_or_item
state_flagr  s                             r;   rG  IPCompleter.dict_key_matches	  s    !!'')22377I"))$*@*@A=I-2\\^*
!!$')I~~c"K#--~~??!	
 0?dmm220
,W I //03t9<
AI(7+099;6I !G&67G
  !''D,B,B(C(EFLLN""=11'M(:(<=L"O#))+ $.c4#8  '',,J1J1J 	 '',, *(*)) 	
 *Gd.G.G '8])01AGaK11,99M<U<UU$]]_MAzq[F=-'11 116G#]3338L$NN6" -  - 2s   Lc                T    U R                  UR                  5      u  p#[        USUSS9$ )zDSame as :any:`unicode_name_matches`, but adopted to new Matcher API.r*  Tr+  )unicode_name_matchesr   r/  r   r   r,  r  s       r;   r{   IPCompleter.unicode_name_matcherM
  s3     !55g6O6OP/)hD
 	
r<   c                    U R                  S5      nUS:  aC  XS-   S n [        R                  " U5      nSU-   R                  5       (       a  SU-   U/4$  S/ 4$ S/ 4$ ! [         a     S/ 4$ f = f)u   Match Latex-like syntax for unicode characters base
on the name of the character.

This does  ``\GREEK SMALL LETTER ETA`` -> ``η``

Works only on valid python 3 identifier, or on combining characters that
will combine to form a valid identifier.
r^   r}   rk   Nar[   )rfindr6  lookupisidentifierr7  )r   slashposrX   r:  s       r;   r_   IPCompleter.unicode_name_matchesU
  s     ::d#b=aZ[!A"))!,H**,,64&=( - 2vr2v  2vs   5A 
A/.A/c                T    U R                  UR                  5      u  p#[        USUSS9$ )uk   Match Latex syntax for unicode characters.

This does both ``\alp`` -> ``\alpha`` and ``\alpha`` -> ``α``
r<  Tr+  )latex_matchesr   r/  r`  s       r;   rz  IPCompleter.latex_name_matcherk
  s3     !..w/H/HI/'H$
 	
r<   c                    UR                  S5      nUS:  aQ  XS nU[        ;   a  U[        U   /4$ [         Vs/ s H  oDR                  U5      (       d  M  UPM     nnU(       a  X54$ gs  snf )u   Match Latex syntax for unicode characters.

This does both ``\alp`` -> ``\alpha`` and ``\alpha`` -> ``α``

.. deprecated:: 8.6
    You can use :meth:`latex_name_matcher` instead.
r^   r}   Nr3  )rd  r   rl   )r   r   rg  rX   r  r  s         r;   rj  IPCompleter.latex_matchesv
  sq     ::d#b=YAM! =+,,, '4Gm||A1mG:% Hs   A*A*c                    U R                  UR                  5      =(       d    / n[        U[        SS9nSUS'   [	        U R
                  5      1US'   U$ )z`Dispatch custom completer.

If a match is found, suppresses all other matchers except for Jedi.
TrF  r   r   )dispatch_custom_completerr   r/  _UNKNOWN_TYPEr'  r  )r   r   r  r  s       r;   r  $IPCompleter.custom_completer_matcher
  sX     00?E21-T
 !y%4T5G5G%H$I !r<   c                   U R                   (       d  gU R                  nUR                  5       (       d  g[        5       nX#l        Xl        UR                  SS5      S   nXCl        U R                  Ul        UR                  U R                  5      (       d)  U R                   R                  U R                  U-   5      nO/ n[        R                  " U R                   R                  U5      UU R                   R                  U R                  5      5       H  n U" U5      nU(       a~  U Vs/ s H  oR                  U5      (       d  M  UPM     n	nU	(       a  U	s  $ UR                  5       n
U Vs/ s H*  oR                  5       R                  U
5      (       d  M(  UPM,     sns  $ M     gs  snf s  snf ! [          a     M  ["         a        gf = f)zO
.. deprecated:: 8.6
    You can use :meth:`custom_completer_matcher` instead.
Nrk   r   )rx  r  r  r
   r]  symbolr   commandr   rl   ri  	s_matchesr  r  flat_matchesr  r   KeyboardInterrupt)r   r   r]  eventcmd	try_magicr`   resrwithcasetext_lows              r;   ro  %IPCompleter.dispatch_custom_completer
  s   
 %%zz||  !
jja #"&"8"8 ~~d//00..88!!C')I I!7!7!A!A#!F''44T5K5KLNAh+.E3a,,t2D3HE'#zz|H'*Ms!ggi.B.B8.LAsMM N,   F
 N $  sH   F6-F,
F,
F6F61'F1F1"F6,
F66
G
GGc           	   #    #    [         R                  " S[        SS9  [        5       n U R                  (       a%  SSKnUR                  5       nUR                  5         OSnU R                  XU R                  S-  S9 H&  nU(       a  Xc;   a  M  Uv   UR                  U5        M(     Wb  UR                  5         [        U R                  5        [        R                   R#                  U R                  [%        [&        R(                  " 5       5      5      n[+        SU5        UR-                  U5        gg! [         a      Nf = f! Wb  UR                  5         [        U R                  5        [        R                   R#                  U R                  [%        [&        R(                  " 5       5      5      n[+        SU5        UR-                  U5        f f = f7f)	a  
Returns an iterator over the possible completions

.. warning::

    Unstable

    This function is unstable, API may change without warning.
    It will also raise unless use in proper context manager.

Parameters
----------
text : str
    Full text of the current input, multi line string.
offset : int
    Integer representing the position of the cursor in ``text``. Offset
    is 0-based indexed.

Yields
------
Completion

Notes
-----
The cursor on a text can either be seen as being "in between"
characters or "On" a character depending on the interface visible to
the user. For consistency the cursor being on "in between" characters X
and Y is equivalent to the cursor being "on" character Y, that is to say
the character the cursor is on is considered as being after the cursor.

Combining characters may span more that one position in the
text.

.. note::

    If ``IPCompleter.debug`` is :any:`True` will yield a ``--jedi/ipython--``
    fake Completion token to distinguish completion returned by Jedi
    and usual IPython completion.

.. note::

    Completions are not completely deduplicated yet. If identical
    completions are coming from different sources this function does not
    ensure that each completion object will only be present once.
zy_complete is a provisional API (as of IPython 6.0). It may change without warnings. Use in corresponding context manager.rU   r   r   Ni  )_timeoutzWriting profiler output to)rN   r   rC   rd   profile_completionscProfileProfileenable_completionsr  r5  rw  disabler&   profiler_output_dirrn   ro   rg   r   uuiduuid4rB  
dump_stats)r   r   r  r8  r  profilerr`   output_paths           r;   r   IPCompleter.completions
  s|    \ 	 >  ;q	J
 u	1''#++-!&&td>\>\]a>a&b!)	 c #  "!$":":; ggll4+C+CSEVW2K@##K0 $ ! 	.	
 #  "!$":":; ggll4+C+CSEVW2K@##K0 $s7   %GA?D4 'BG4E?E EE BGGc             #  h  ^#    [         R                  " 5       U-   nUSU n[        X5      u  pg[        U R                  5      m      SU4S jjnU R                  XUS9n	U	R                  5        V
Vs0 s H  u  pU" X5      (       d  M  X_M     nn
nTU	;   a  [        [        U	T   5      S   OSn[        U5      nU(       a  U H  n UR                  n[        UR                  5      [        UR                   5      -
  nUS:X  a  [#        U5      nOSn[%        UU-
  UUR                  UUS	S
9v   [         R                  " 5       U:  d  M    O   U HO  n[        UR                  5      [        UR                   5      -
  n[%        UU-
  UUR                  [&        S	SS9v   MQ     U(       a\  U(       aU  U R                  (       aD  UR)                  [+        [        UR-                  5       5      5      S   5      n[%        UUSSSSS9v   / n/ nUR                  5        H  u  nnUS   nUR)                  U5      nUR/                  SS5      nU(       a  UOUnUR1                  U5      (       d   eUS    HC  n[%        UUUR2                  USUR                  =(       d    [&        S9nUR5                  U5        ME     M     [7        U R9                  UU R;                  U5      -   5      5      S[<          Sh  vN   gs  snn
f ! [         a#    U R                  (       a  [        SU5        Sn GNVf = f N;7f)a  
Core completion module.Same signature as :any:`completions`, with the
extra `timeout` parameter (in seconds).

Computing jedi's completion ``.type`` can be quite expensive (it is a
lazy property) and can require some warm-up, more warm up than just
computing the ``name`` of a completion. The warm-up can be :

    - Long warm-up the first time a module is encountered after
    install/update: actually build parse/inference tree.

    - first time the module is encountered in a session: load tree from
    disk.

We don't want to block completions for tens of seconds so we give the
completer a "budget" of ``_timeout`` seconds per invocation to compute
completions types, the completions that have not yet been computed will
be marked as "unknown" an will have a chance to be computed next round
are things get cached.

Keep in mind that Jedi is not the only thing treating the completion so
keep the timeout short-ish as if we take more than 0.3 second we still
have lots of processing to do.

Nc                   > UT:g  $ r   r8   )r  r  jedi_matcher_ids     r;   is_non_jedi_result4IPCompleter._completions.<locals>.is_non_jedi_result>  s     00r<   )r   r   r^  r   r8   zError in Jedi getting type of functionr[   r@  r   )r   r   r   r   r   r   r   z--jedi/ipython--r  none)r   r   r   r   r   r   r   F)r   r   r   r   r   r   )r  r   r  r   r   zTypeGuard[SimpleMatcherResult])time	monotonicr!  r'  r  	_completer  r0   r   r  r   r  r  rB  rm   r   r   rS  r   rp  rd  r  valuesrn  r   r   r  r2  _deduplicate_sortMATCHES_LIMIT)r   r   r  r  deadliner  r   r  r  rZ  r  r  non_jedi_resultsjedi_matchesiter_jmjmr9   deltar   some_start_offsetr   sortableoriginmatched_textstart_offset
is_ordered	containersimple_completionrO  r  s                                @r;   r  IPCompleter._completions  sF    4 >>#h.7F#%7	%J")$*<*<=	1!	1/2	1+	1
 ..] ! 
 '.mmo<
&5"
!&5 J&5 	 <
 ') #W_%=>}M 	 |$!GGE
 B001C4DDJ& / 3I "I v~%+&(&:&:&++4)/1 1 >>#h.) , B,,-BKK0@@Eun))"   , &T*113456HI! ''  %'%'.446NFF!"45L!<<5LIu5J#-8I ??<0000%+M%:!'&*//" *//@=
   , &; 7* ))'DJJx4H*HIJ]
 	
 	
m<
" ! !zz>C E!J	
sP   A1L24K:K:8L2
L A3L2F'L24L05L2 )L-)L2,L--L2c                    [         R                  " S[        5        U R                  X#USS9n[	        U R
                  5      nU R                  UU1SS9$ )a  Find completions for the given text and line context.

Note that both the text and the line_buffer are optional, but at least
one of them must be given.

Parameters
----------
text : string, optional
    Text to perform the completion on.  If not given, the line buffer
    is split using the instance's CompletionSplitter object.
line_buffer : string, optional
    If not given, the completer attempts to obtain the current line
    buffer via readline.  This keyword allows clients which are
    requesting for text completions in non-readline contexts to inform
    the completer of the entire text.
cursor_pos : int, optional
    Index of the cursor in the full line buffer.  Should be provided by
    remote frontends where kernel has no access to frontend state.

Returns
-------
Tuple of two items:
text : str
    Text that was actually used in the completion.
matches : list
    A list of completion matches.

Notes
-----
    This API is likely to be deprecated and replaced by
    :any:`IPCompleter.completions` in the future.

zn`Completer.complete` is pending deprecation since IPython 6.0 and will be replaced by `Completer.completions`.r   )r  r^  r   r   Tskip_matchersabort_if_offset_changes)rN   r   PendingDeprecationWarningr  r'  r  _arrange_and_extract)r   r   r  r^  rZ  r  s         r;   r   IPCompleter.complete  sm    D 	 O/	1 ..#ST ! 
 *$*<*<=((*+$( ) 
 	
r<   c                   / n/ nS nUR                  5        Hw  u  pxXr;   a  M  US   (       d  M  U(       d  US   nU(       a  US   U:w  a    OEUR                  SS5      (       a  UR                  US   5        Mc  UR                  US   5        My     U(       d  SnUU R                  XPR	                  U5      -   5       V	s/ s H  oR
                  PM     sn	4$ s  sn	f )Nr   r   r   Fr[   )r  rn  r  r  r  r   )
r   rZ  r  r  r  r   most_recent_fragmentr  r  r'  s
             r;   r   IPCompleter._arrange_and_extract  s     02.0#")--/J*-(''-.@'A$'-.2FFzz)U++vm45} 56 #2" $#% # --g

88L.LM&
MqFFM&
 
 	
 &
s    C)r  r   r   c                  Uc  Uc  [        U5      O
[        U5      nU R                  (       a  [        R                  U l        U(       d  U(       a  UR                  S5      U   nU(       d$  U(       a  U R                  R                  X25      OSnUc  UnX0l        U R                  SU U l	        U(       d  Un[        UUUU[        S9n0 n[        U R                  5      n[        5       n	[        U R                   ["        SS9 V
s0 s H  n
[        U
5      U
_M     nn
UR%                  5        GH  u  p[        U
5      nXR&                  ;   a  M"  X;   a  [(        R*                  " SU S35        X;   a  MH   [-        U
5      (       a  [/        U
" U5      [0        S	9nO2[3        U
5      (       a	  U
" U5      nO[5        U
5      n[7        S
U 35      eUR?                  SUR@                  5      US'   U	(       Gd   UR?                  SS5      n[C        U RD                  [F        5      (       a  U RD                  R?                  US5      OU RD                  nUSL =(       d    U=(       a    USL=(       a    [I        U5      nU(       av  UR?                  S[        5       5      n[C        U[J        5      (       a  [        U5      nO[        U5      nUU-
  n	0 nUR%                  5        H  u  nnUU	;  d  M  UUU'   M     UnXU'   GM     U RM                  UU1SS9u  nnUU l'        U$ s  sn
f !   [8        R:                  " [8        R<                  " 5       6    GM  = f)a  
Like complete but can also returns raw jedi completions as well as the
origin of the completion text. This could (and should) be made much
cleaner but that will be simpler once we drop the old (and stateful)
:any:`complete` API.

With current provisional API, cursor_pos act both (depending on the
caller) as the offset in the ``text`` or ``line_buffer``, or as the
``column`` when passing multiline strings this could/should be renamed
but would add extra noise.

Parameters
----------
cursor_line
    Index of the line the cursor is on. 0 indexed.
cursor_pos
    Position of the cursor in the current line/line_buffer/text. 0
    indexed.
line_buffer : optional, str
    The current line the cursor is in, this is mostly due to legacy
    reason that readline could only give a us the single current line.
    Prefer `full_text`.
text : str
    The current "token" the cursor is in, mostly also for historical
    reasons. as the completer would trigger only after the current line
    was parsed.
full_text : str
    Full text of the current cell.

Returns
-------
An ordered dictionary where keys are identifiers of completion
matchers and values are ``MatcherResult``s.
Nr   r[   )r   r   r   r   r   T)r  reversezDuplicate matcher ID: r{  r   zUnsupported API version r   r   Fr   r  )(rm   rr  r|  r}  rs  r   rZ  r`  r  r   r   r  r'  r  rd   r  r  r%  r  r~  rN   r   r   r/  rp  r  r   r  re   
excepthookexc_inforn  r   r  r  r   r  r   r  r  )r   r   r^  r  r   r   r   rZ  r  suppressed_matchersr   r  
matcher_idr  r   suppression_recommendedsuppression_configshould_suppresssuppression_exceptionsto_suppressnew_resultsprevious_matcher_idprevious_resultr{   r  s                            r;   r  IPCompleter._complete  sN   N -1\[)s4yJ%..DN #//$/<KEP((AVX 
 K '!%!1!1+:!>#I#&#
 -/)$*<*<=(+ "#8$
 G$g- 	 
 $,>>#3J(1J222$ 6zl!DE0!'**=MF $G,,$W-F":7"CK$'?}%MNN *04F)VF%&&AGB' "$"B"BDII 4488TJ99 # (4/ W/U5Gu5T#2 *&1  
 #7=zz)358* ""98DD&)*A&B&)(m*58N*N'"$K@G<+_.6II?NK(;< AP *G"(J $4B .. ++$) / 

7 g
< /s   L6$L L 4L  (Mc                    0 nU  H0  nUR                   nX1;  d  X   R                  [        :X  d  M,  X!U'   M2     UR                  5       $ r   )r   r   rp  r  )r  filtered_matchesr  r   s       r;   r  IPCompleter._deduplicate  sM     68E::D,#)..-?).&   &&((r<   c                    [        U S S9$ )Nc                ,    [        U R                  5      $ r   )r   r   r  s    r;   r  #IPCompleter._sort.<locals>.<lambda>  s    -DQVV-Lr<   r  )r  )r  s    r;   r  IPCompleter._sort  s    g#LMMr<   c                T    U R                  UR                  5      u  p#[        USUSS9$ )zASame as :any:`fwd_unicode_match`, but adopted to new Matcher API.r*  Tr+  )fwd_unicode_matchr   r/  r`  s       r;   r|  IPCompleter.fwd_unicode_matcher  s3     !2273L3LM/)hD
 	
r<   c                  ^ UR                  S5      nUS:  a  XS-   S nUR                  5       nU R                   Vs/ s H  oUR                  U5      (       d  M  UPM     nnU(       a  X64$ U R                   Vs/ s H  oTU;   d  M
  UPM     nnU(       a  X64$ UR	                  S5      nU R                   V^s/ s H!  m[        U4S jU 5       5      (       d  M  TPM#     nnU(       a  X64$ ggs  snf s  snf s  snf )az  
Forward match a string starting with a backslash with a list of
potential Unicode completions.

Will compute list of Unicode character names on first call and cache it.

.. deprecated:: 8.6
    You can use :meth:`fwd_unicode_matcher` instead.

Returns
-------
At tuple with:
    - matched text (empty if no matches)
    - list of potential completions, empty tuple  otherwise)
r^   r}   rk   NrA   c              3  ,   >#    U  H	  oT;   v   M     g 7fr   r8   )r_   ur  s     r;   rb   0IPCompleter.fwd_unicode_match.<locals>.<genexpr>  s     4NX!VXs   r3  )rd  upperunicode_namesrl   r   all)r   r   rg  rX   supr  
candidatessplitsups        `  r;   r  IPCompleter.fwd_unicode_match  s    @ ::d#b= \^$A'')C%)%7%7M%7<<;L!%7JM}$%)%7%7D%7!8!%7JD}$yy~H---a4NX4N1N-   }$ # N Es#   C0C0;	C5C5:C:C:c                   U R                   cX  / n[        SS5       H2  n UR                  [        R                  " [        U5      5      5        M4     [        [        5      U l         U R                   $ ! [         a     Mc  f = f)zmList of names of unicode code points that can be completed.

The list is lazily initialized on first access.
r   i   )	ry  ranger  r6  r   chrr  _unicode_name_compute_UNICODE_RANGES)r   rA  r`   s      r;   r  IPCompleter.unicode_names  su     &E1\*LL!1!1#a&!9: +
 #8"HD"""	 " s   .A22
B ?B )__funcParamsRegexr}  ry  r  rq  rx  rt  rs  ro  r  rl  r  rw  ri  r  rs  rj  rk  rZ  r  r   )NNNN)r   zList[Matcher]r   )r   r   )r   r   r   r   )r   r   r   r   )r  r   r   r   r   r   r   r   )r   r   r   zIterable[str])r:   r   r   z	List[Any]r   r   )r   r   r   zTuple[str, List[str]]r   r   r   Tuple[str, Sequence[str]])r   r   r  r   r   Iterator[Completion])r   r   r  r   r   r  )NNN)r   r  )rZ  zDict[str, MatcherResult]r  zSet[str]r  r   )r   _CompleteResult)r  Sequence[AnyCompletion]r   zIterable[AnyCompletion])r  r  )r   r   )DrD   rE   rF   rG   rH   r,   r]  r(   r  
UnionTrait	DictTraitr  r  r  	ListTraitr+   r~  r)   r  r  r  r  rb  r   rc  r  r  rr  rp  context_matcherr  r  r  r  ru  r  rv  r  r  r  r   r  r
  r  r  r   staticmethodrC  r  rG  r{  r_  rz  rj  r  ro  r   r  r   r  r  r  r  r|  r  r  rI   r  r  s   @r;   r?   r?     s   IX	* 	* N #-			$t*E FG#. 
cc/  2 
 
cc  !	 
cc  	 
cc  5
 
cc  T 
cc 
 ",Q 
cc 
    IMX4t  <	&'2 F FTCl  ,\ G G%N G G$  :;

 <

R  R /2R :=R 	&R h A& ',4 D G G
N`  . 
 
sj 
 
  * 
 
.  2hL1\B
H6
p
)
  
 "&	
B AE4 b%4bH )()	 ) ) N N 
 
;z # #r<   c           	         / nU  HF  u  p#[        X#5       H2  n UR                  [        R                  " [	        U5      5      5        M4     MH     U$ ! [
         a     MI  f = fr   )r  r  r6  r   r  r  )rangesrA  r   stopr`   s        r;   r  r  
  s]    E
u#A[--c!f56 $  L  s   .A
AA)ignore)ro   r   r   zTuple[str, bool, str])ro   r   rq   r   rr   r   r   r   )r   r   r   zTypeGuard[MatcherAPIv1])r   r   r   zTypeGuard[MatcherAPIv2])r  r   r   zTypeGuard[Sized])r  r   r   zTypeGuard[Iterator])r  r   r   r   )r  zOptional[float]r  r   r   r   )r   r   )r   r   r   _ICr   r  )r   r   r   r  r;  r   r   r  )r  r   r   zUnion[str, None]r   )
r  z6List[Union[str, bytes, Tuple[Union[str, bytes], ...]]]r  r   rM  r   r  z'Optional[Tuple[Union[str, bytes], ...]]r   z)Tuple[str, int, Dict[str, _DictKeyState]])r   r   r]  r   r  r   r   r   )r   r   r  r   r   zTuple[int, int]r  r  r   )NF)
r  zSequence[str]r   r   r,  r   r-  r   r   r   )r  zList[Tuple[int, int]]r   r   )rH   
__future__r   builtinsr  r  rl  r  r  r  rn   rW  r  re   r  r  r6  r  rN   astr   collectionsr   
contextlibr   dataclassesr   	functoolsr   r	   typesr
   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   IPython.core.guarded_evalr   r   IPython.core.errorr   IPython.core.inputtransformer2r   IPython.core.latex_symbolsr   r   IPython.core.oinspectr   IPython.testing.skipdoctestr    IPython.utilsr!   IPython.utils.decoratorsr"   IPython.utils.dir2r#   r$   IPython.utils.docsr%   IPython.utils.pathr&   IPython.utils.processr'   	traitletsr(   r)   r*   r  r+   r  r  r,   traitlets.config.configurabler-   r|  __skip_doctest__r@  settingscase_insensitive_completionjedi.api.helpersjedi.api.classesr  ImportErrorversion_infor0   typing_extensionsr1   r2   r3   r4   r5   r6   objectr  r  rf   PROTECTABLESr  rp  r  FutureWarningrC   rP   rR   rY   rh   ru   rx   r   r   _JediCompletionLiker   r   r   r   r   AnyMatcherCompletionr   r   r   r   r   r   r   r   r   r   r  r	  r  r  r   r%  r'  r   r  r  r:  rH  rb  rY  rJ  r>   r  Flagr  r  r  binocthexr  r  r  r!  r(  r1  r.  r>  r=  rD  rS  r   r  rX  rK  r/  r?   r  r8   r<   r;   <module>r     s  jf #       	 	  
       # % ! . !   " F & 4 J / 4 " 3 4 7 0 +	 	 	 7   05DMM-N
 ,1A1AW1LXX
 KIHII  !"45 
&<<7L*L   H		- 	 	  *E F   8* &2 %,P@; ;. 13FFG G7 G7TK K0 $ tVHMI,i I NI/+ / 02BBC )=zJ #< #< #<N )+==> *H    13E EFi F8  <56 6

%
&
. !% $	%% % 	%P3H6 ,!< z'T HM 8;v <<7-F0F0+ 0+hy yv4DII 
 H 

 =A	^'
@^'^' ^' :	^'
 /^'B:8D"  'T  :,U< sM)* ZZ,. h # %	--
- - 	-
 - t#) t#l1W`  Ns   ;N: :OO