a
    lcs                     @   sF  d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZmZ ddlmZ ddlmZmZ ddlmZmZ ddlmZ ddlmZ ddl m!Z! dd Z"dd Z#dd Z$G dd dZ%G dd de%Z&G dd de%Z'G dd de'Z(G d d! d!e(Z)G d"d# d#e'Z*dS )$a`  
There are a couple of classes documented in here:

- :class:`.BaseName` as an abstact base class for almost everything.
- :class:`.Name` used in a lot of places
- :class:`.Completion` for completions
- :class:`.BaseSignature` as a base class for signatures
- :class:`.Signature` for :meth:`.Script.get_signatures` only
- :class:`.ParamName` used for parameters of signatures
- :class:`.Refactoring` for refactorings
- :class:`.SyntaxError` for :meth:`.Script.get_syntax_errors` only

These classes are the much biggest part of the API, because they contain
the interesting information about all operations.
    N)Path)Optional)search_ancestor)settings)debug)unite)memoize_method)	MixedName)
ImportNameSubModuleName)StubModuleValue)convert_namesconvert_values)ValueSetHasNoContext)KeywordName)completion_cache)filter_follow_importsc                 C   s   t | dd dS )Nc                 S   s
   | j pdS N)r   r   )	start_poss r   L/var/www/html/django/DPS/env/lib/python3.9/site-packages/jedi/api/classes.py<lambda>%       z*_sort_names_by_start_pos.<locals>.<lambda>key)sorted)namesr   r   r   _sort_names_by_start_pos$   s    r    c                    sX   z|  }W n ty"   g  Y S 0 t| }dd | D } fddt|D S )zi
    List sub-definitions (e.g., methods in class).

    :type scope: Scope
    :rtype: list of Name
    c                 S   s   g | ]}|qS r   r   ).0namer   r   r   
<listcomp>4   r   z!defined_names.<locals>.<listcomp>c                    s   g | ]}t  |qS r   )Namer!   ninference_stater   r   r#   5   r   )
as_contextr   nextZget_filtersvaluesr    )r(   valuecontextfilterr   r   r'   r   defined_names(   s    
r/   c                 C   s   dd | D S )Nc                 S   s   g | ]}t |j|jqS r   )r$   r(   r"   r!   cr   r   r   r#   9   r   z*_values_to_definitions.<locals>.<listcomp>r   )r+   r   r   r   _values_to_definitions8   s    r2   c                   @   s|  e Zd ZdZddddddddddddd	Zed
d ddi D Zdd Ze	dd Z
eee dddZedd Zedd Zedd Zdd Zedd Zedd  Zd!d" Zd#d$ ZdMd'd(Zd)d* Zd+d, Zed-d. Zed/d0 Zd1d2 Zd3d4 Zed5d%d%d%d%d6d7d8Z ed9d%d%d:d;d<Z!d=d> Z"d?d@ Z#dNdBdCZ$dOdDdEZ%dFdG Z&dHdI Z'dJdK Z(dLS )PBaseNamezI
    The base class for all definitions, completions and signatures.
    zos.pathosio	functoolscollectionssocketsqlite3)	posixpathZ
riscospathntpathZ
os2emxpathZmacpathgenericpathposix_io
_functools_collections_socketZ_sqlite3c                 c   s$   | ]\}}t |d |fV  qdS ).N)tuplesplit)r!   kvr   r   r   	<genexpr>O   r   zBaseName.<genexpr>zargparse._ActionsContainerzargparse.ArgumentParserc                 C   s   || _ || _t| jt| _d S N)_inference_state_name
isinstancer   Z
is_keyword)selfr(   r"   r   r   r   __init__S   s    zBaseName.__init__c                 C   s
   | j  S rH   )rJ   get_root_contextrL   r   r   r   _get_module_context[   s    zBaseName._get_module_context)returnc                 C   s4   |   }| s| s0|    }|dur0|S dS )zT
        Shows the file path of a module. e.g. ``/usr/lib/python3.9/os.py``
        N)rP   is_stubis_compiledZ
py__file__)rL   modulepathr   r   r   module_pathb   s    zBaseName.module_pathc                 C   s
   | j  S )z
        Name of variable/function/class/module.

        For example, for ``x = None`` it returns ``'x'``.

        :rtype: str or None
        )rJ   get_public_namerO   r   r   r   r"   q   s    	zBaseName.namec                 C   sj   | j j}d}|dur:| }|dur:|jdkr:| r:d}t| j tsJ|rb| j  D ]}|j  S | j jS )a  
        The type of the definition.

        Here is an example of the value of this attribute.  Let's consider
        the following source.  As what is in ``variable`` is unambiguous
        to Jedi, :meth:`jedi.Script.infer` should return a list of
        definition for ``sys``, ``f``, ``C`` and ``x``.

        >>> from jedi import Script
        >>> source = '''
        ... import keyword
        ...
        ... class C:
        ...     pass
        ...
        ... class D:
        ...     pass
        ...
        ... x = D()
        ...
        ... def f():
        ...     pass
        ...
        ... for variable in [keyword, f, C, x]:
        ...     variable'''

        >>> script = Script(source)
        >>> defs = script.infer()

        Before showing what is in ``defs``, let's sort it by :attr:`line`
        so that it is easy to relate the result to the source code.

        >>> defs = sorted(defs, key=lambda d: d.line)
        >>> print(defs)  # doctest: +NORMALIZE_WHITESPACE
        [<Name full_name='keyword', description='module keyword'>,
         <Name full_name='__main__.C', description='class C'>,
         <Name full_name='__main__.D', description='instance D'>,
         <Name full_name='__main__.f', description='def f'>]

        Finally, here is what you can get from :attr:`type`:

        >>> defs = [d.type for d in defs]
        >>> defs[0]
        'module'
        >>> defs[1]
        'class'
        >>> defs[2]
        'instance'
        >>> defs[3]
        'function'

        Valid values for type are ``module``, ``class``, ``instance``, ``function``,
        ``param``, ``path``, ``keyword``, ``property`` and ``statement``.

        FNZimport_fromT)	rJ   	tree_nameget_definitiontypeis_definitionrK   r   inferapi_type)rL   rX   resolve
definitionr,   r   r   r   rZ   |   s    9
zBaseName.typec                 C   s   |    S )aP  
        The module name, a bit similar to what ``__name__`` is in a random
        Python module.

        >>> from jedi import Script
        >>> source = 'import json'
        >>> script = Script(source, path='example.py')
        >>> d = script.infer()[0]
        >>> print(d.module_name)  # doctest: +ELLIPSIS
        json
        )rP   Z
py__name__rO   r   r   r   module_name   s    zBaseName.module_namec                 C   s2   |    }t|tr*tdd |jD S | S )z<
        Returns True, if this is a builtin module.
        c                 s   s   | ]}|  V  qd S rH   )rS   )r!   rF   r   r   r   rG      r   z-BaseName.in_builtin_module.<locals>.<genexpr>)rP   	get_valuerK   r   anyZnon_stub_value_setrS   )rL   r,   r   r   r   in_builtin_module   s    
zBaseName.in_builtin_modulec                 C   s   | j j}|du rdS |d S )z7The line where the definition occurs (starting with 1).Nr   rJ   r   rL   r   r   r   r   line   s    zBaseName.linec                 C   s   | j j}|du rdS |d S )z9The column where the definition occurs (starting with 0).N   rd   re   r   r   r   column   s    zBaseName.columnc                 C   s2   | j jdu rdS | j j }|du r,| j jS |jS )z
        The (row, column) of the start of the definition range. Rows start with
        1, columns start with 0.

        :rtype: Optional[Tuple[int, int]]
        N)rJ   rX   rY   r   )rL   r_   r   r   r   get_definition_start_position   s    z&BaseName.get_definition_start_positionc                 C   s`   | j jdu rdS | j j }|du r.| j jjS | jdv rZ| }|jdkrT| jS |jS |jS )z
        The (row, column) of the end of the definition range. Rows start with
        1, columns start with 0.

        :rtype: Optional[Tuple[int, int]]
        N)functionclassnewline)rJ   rX   rY   end_posrZ   Zget_last_leafZget_previous_leaf)rL   r_   Z	last_leafr   r   r   get_definition_end_position   s    



z$BaseName.get_definition_end_positionFTc                 C   sL   t | jtr|rdS |  }|r$|S |  }|r@|r@|d | S || S dS )ai  
        Return a document string for this completion object.

        Example:

        >>> from jedi import Script
        >>> source = '''\
        ... def f(a, b=1):
        ...     "Document for function f."
        ... '''
        >>> script = Script(source, path='example.py')
        >>> doc = script.infer(1, len('def f'))[0].docstring()
        >>> print(doc)
        f(a, b=1)
        <BLANKLINE>
        Document for function f.

        Notice that useful extra information is added to the actual
        docstring, e.g. function signatures are prepended to their docstrings.
        If you need the actual docstring, use ``raw=True`` instead.

        >>> print(script.infer(1, len('def f'))[0].docstring(raw=True))
        Document for function f.

        :param fast: Don't follow imports that are only one level deep like
            ``import foo``, but follow ``from foo import bar``. This makes
            sense for speed reasons. Completing `import a` is slow if you use
            the ``foo.docstring(fast=False)`` on every object, because it
            parses all libraries starting with ``a``.
         z

N)rK   rJ   r
   _get_docstring_get_docstring_signature)rL   rawfastdocZsignature_textr   r   r   	docstring  s    zBaseName.docstringc                 C   s
   | j  S rH   )rJ   Z	py__doc__rO   r   r   r   rp   7  s    zBaseName._get_docstringc                 C   s   d dd | jddD S )N
c                 s   s   | ]}|  V  qd S rH   )	to_string)r!   	signaturer   r   r   rG   ;  s   z4BaseName._get_docstring_signature.<locals>.<genexpr>T)for_docstring)join_get_signaturesrO   r   r   r   rq   :  s    

z!BaseName._get_docstring_signaturec                 C   s   | j }| jj}|dkr(|d | j  S |dv s8|du rV|dkrDd}|d | j  S |jddpd|}|jd	d
}tdd|}tdd|	 }|S )aZ  
        A description of the :class:`.Name` object, which is heavily used
        in testing. e.g. for ``isinstance`` it returns ``def isinstance``.

        Example:

        >>> from jedi import Script
        >>> source = '''
        ... def f():
        ...     pass
        ...
        ... class C:
        ...     pass
        ...
        ... variable = f if random.choice([0,1]) else C'''
        >>> script = Script(source)  # line is maximum by default
        >>> defs = script.infer(column=3)
        >>> defs = sorted(defs, key=lambda d: d.line)
        >>> print(defs)  # doctest: +NORMALIZE_WHITESPACE
        [<Name full_name='__main__.f', description='def f'>,
         <Name full_name='__main__.C', description='class C'>]
        >>> str(defs[0].description)
        'def f'
        >>> str(defs[1].description)
        'class C'

        param )rj   rk   rT   instanceNrj   defT)Zinclude_setitemF)Zinclude_prefixz	#[^\n]+\nz\s+)
rZ   rJ   rX   rw   rW   rY   get_coderesubstrip)rL   typrX   r_   txtr   r   r   description@  s    zBaseName.descriptionc                 C   sb   | j jsdS | j jdd}|du r&dS t|}z| j|d  |d< W n tyV   Y n0 d|S )a  
        Dot-separated path of this object.

        It is in the form of ``<module>[.<submodule>[...]][.<object>]``.
        It is useful when you want to look up Python manual of the
        object at hand.

        Example:

        >>> from jedi import Script
        >>> source = '''
        ... import os
        ... os.path.join'''
        >>> script = Script(source, path='example.py')
        >>> print(script.infer(3, len('os.path.join'))[0].full_name)
        os.path.join

        Notice that it returns ``'os.path.join'`` instead of (for example)
        ``'posixpath.join'``. This is not correct, since the modules name would
        be ``<module 'posixpath' ...>```. However most users find the latter
        more practical.
        NT)Zinclude_module_namesr   rB   )rJ   is_value_nameZget_qualified_nameslist_mappingKeyErrorrz   )rL   r   r   r   r   	full_nameq  s    zBaseName.full_namec                 C   s   | j jsdS | j   S )zM
        Returns True if the current name is defined in a stub file.
        F)rJ   r   rN   rR   rO   r   r   r   rR     s    zBaseName.is_stubc                 C   s(   | j j}|du rdS | o&|jjdkS )z
        Checks if a name is defined as ``self.foo = 3``. In case of self, this
        function would return False, for foo it would return True.
        NFtrailer)rJ   rX   r[   parentrZ   )rL   rX   r   r   r   is_side_effect  s    zBaseName.is_side_effectzgoto on name)follow_importsfollow_builtin_imports
only_stubsprefer_stubsc                   sD    j jsg S  j  }|r$t||}t|||d} fdd|D S )ag  
        Like :meth:`.Script.goto` (also supports the same params), but does it
        for the current name. This is typically useful if you are using
        something like :meth:`.Script.get_names()`.

        :param follow_imports: The goto call will follow imports.
        :param follow_builtin_imports: If follow_imports is True will try to
            look up names in builtins (i.e. compiled or extension modules).
        :param only_stubs: Only return stubs for this goto call.
        :param prefer_stubs: Prefer stubs to Python objects for this goto call.
        :rtype: list of :class:`Name`
        r   r   c                    s&   g | ]}| j kr n
t j|qS r   rJ   r$   rI   r%   rO   r   r   r#     s   z!BaseName.goto.<locals>.<listcomp>)rJ   r   gotor   r   )rL   r   r   r   r   r   r   rO   r   r     s    


zBaseName.gotozinfer on namer   c                   sf   |r|rJ  j jsg S t j gdd}ttdd |D ||d}dd |D } fdd|D S )	a  
        Like :meth:`.Script.infer`, it can be useful to understand which type
        the current name has.

        Return the actual definitions. I strongly recommend not using it for
        your completions, because it might slow down |jedi|. If you want to
        read only a few objects (<=20), it might be useful, especially to get
        the original docstrings. The basic problem of this function is that it
        follows all results. This means with 1000 completions (e.g.  numpy),
        it's just very, very slow.

        :param only_stubs: Only return stubs for this goto call.
        :param prefer_stubs: Prefer stubs to Python objects for this type
            inference call.
        :rtype: list of :class:`Name`
        Tr   c                 s   s   | ]}|  V  qd S rH   )r\   r%   r   r   r   rG     r   z!BaseName.infer.<locals>.<genexpr>r   c                 S   s   g | ]
}|j qS r   )r"   r0   r   r   r   r#     r   z"BaseName.infer.<locals>.<listcomp>c                    s&   g | ]}| j kr n
t j|qS r   r   r%   rO   r   r   r#     s   )rJ   r   r   r   r   Z	from_sets)rL   r   r   r   r+   Zresulting_namesr   rO   r   r\     s    
zBaseName.inferc                 C   s   | j jsdS | jdv rP| j jdurP| j j }t|ddd}|  | }n| j j	}|du rddS |j
du rv|j	}qdt| j|j
S )zT
        Returns the parent scope of this identifier.

        :rtype: Name
        N)rj   rk   r|   ZfuncdefZclassdefZ
file_input)rJ   r   rZ   rX   rY   r   rP   Zcreate_valuer)   Zparent_contextr"   r$   rI   )rL   Zcls_or_func_noder   r-   r   r   r   r     s    

zBaseName.parentc                 C   s(   d| j j| jrdnd| jp| j| jf S )Nz<%s %sname=%r, description=%r>Zfull_ro   )	__class____name__r   r"   r   rO   r   r   r   __repr__  s    
zBaseName.__repr__r   c                 C   s\   | j jsdS | j  j}|du r$dS | j jd d }t|| d}d|||| d  S )aI  
        Returns the line of code where this object was defined.

        :param before: Add n lines before the current line to the output.
        :param after: Add n lines after the current line to the output.

        :return str: Returns the line(s) of code or an empty string if it's a
                     builtin.
        ro   Nr   rg   )rJ   r   rN   Z
code_linesr   maxrz   )rL   beforeafterlinesindexstart_indexr   r   r   get_line_code  s    
zBaseName.get_line_codec                 C   sd   | j jdkrg S |r,| j jdkr,|  s,g S t| j trF| j   S t| j gdd}dd |D S )NpropertyZ	statementTr   c                 S   s"   g | ]}|   D ]}|qqS r   )r\   get_signatures)r!   r"   sigr   r   r   r#   ;  r   z,BaseName._get_signatures.<locals>.<listcomp>)rJ   r]   rR   rK   r	   Zinfer_compiled_valuer   r   )rL   ry   r   r   r   r   r{   ,  s    zBaseName._get_signaturesc                    s    fdd   D S )z
        Returns all potential signatures for a function or a class. Multiple
        signatures are typical if you use Python stubs with ``@overload``.

        :rtype: list of :class:`BaseSignature`
        c                    s   g | ]}t  j|qS r   )BaseSignaturerI   )r!   r   rO   r   r   r#   D  s   z+BaseName.get_signatures.<locals>.<listcomp>)r{   rO   r   rO   r   r   =  s    
zBaseName.get_signaturesc                 C   s   t | j  S )z
        Uses type inference to "execute" this identifier and returns the
        executed objects.

        :rtype: list of :class:`Name`
        )r2   rJ   r\   Zexecute_with_valuesrO   r   r   r   executeI  s    zBaseName.executec                 C   s   | j   S )a*  
        Returns type hints like ``Iterable[int]`` or ``Union[int, str]``.

        This method might be quite slow, especially for functions. The problem
        is finding executions for those functions to return something like
        ``Callable[[int, str], str]``.

        :rtype: str
        )rJ   r\   get_type_hintrO   r   r   r   r   R  s    
zBaseName.get_type_hintN)FT)r   r   )F))r   
__module____qualname____doc__r   dictitemsZ_tuple_mappingrM   r   rP   r   r   r   rV   r"   rZ   r`   rc   rf   rh   ri   rn   ru   rp   rq   r   r   rR   r   r   Zincrease_indent_cmr   r\   r   r   r   r{   r   r   r   r   r   r   r   r3   <   sr   



F
	


+
0
&	
#!

	r3   c                       s   e Zd ZdZd fdd	Zdd Zedd Zed	d
 Zd fdd	Z	 fddZ
 fddZ fddZe fddZdd Zdd Z  ZS )
Completionz
    ``Completion`` objects are returned from :meth:`.Script.complete`. They
    provide additional information about a completion.
    Nc                    s0   t  || || _|| _|| _|| _g | _d S rH   )superrM   _like_name_length_stack	_is_fuzzy_cached_nameZ_same_name_completions)rL   r(   r"   stackZlike_name_lengthZis_fuzzyZcached_namer   r   r   rM   d  s    zCompletion.__init__c                 C   s<   d}t jr| jdkrd}| j }|r4|| jd  }|| S )Nro   rj   ()r   Zadd_bracket_after_functionrZ   rJ   rW   r   )rL   Z	like_nameappendr"   r   r   r   	_completeq  s    
zCompletion._completec                 C   s   | j r
dS | dS )a!  
        Only works with non-fuzzy completions. Returns None if fuzzy
        completions are used.

        Return the rest of the word, e.g. completing ``isinstance``::

            isinstan# <-- Cursor is here

        would return the string 'ce'. It also adds additional stuff, depending
        on your ``settings.py``.

        Assuming the following function definition::

            def foo(param=0):
                pass

        completing ``foo(par`` would give a ``Completion`` which ``complete``
        would be ``am=``.
        NT)r   r   rO   r   r   r   complete|  s    zCompletion.completec                 C   s
   |  dS )aB  
        Similar to :attr:`.name`, but like :attr:`.name` returns also the
        symbols, for example assuming the following function definition::

            def foo(param=0):
                pass

        completing ``foo(`` would give a ``Completion`` which
        ``name_with_symbols`` would be "param=".

        F)r   rO   r   r   r   name_with_symbols  s    zCompletion.name_with_symbolsFTc                    s   | j dkrd}t j||dS )z>
        Documented under :meth:`BaseName.docstring`.
           F)rr   rs   )r   r   ru   )rL   rr   rs   r   r   r   ru     s    
zCompletion.docstringc                    s2    j d ur(t j  j  fddS t  S )Nc                      s      S rH   
_get_cacher   rO   r   r   r     r   z+Completion._get_docstring.<locals>.<lambda>)r   r   get_docstringrJ   rW   r   rp   rO   r   rO   r   rp     s    

zCompletion._get_docstringc                    s2    j d ur(t j  j  fddS t  S )Nc                      s      S rH   r   r   rO   r   r   r     r   z5Completion._get_docstring_signature.<locals>.<lambda>)r   r   Zget_docstring_signaturerJ   rW   r   rq   rO   r   rO   r   rq     s    

z#Completion._get_docstring_signaturec                    s   t  jt   t   fS rH   )r   rZ   rq   rp   rO   r   r   r   r     s    zCompletion._get_cachec                    s0    j dur(t j  j  fddS t jS )z9
        Documented under :meth:`BaseName.type`.
        Nc                      s      S rH   r   r   rO   r   r   r     r   z!Completion.type.<locals>.<lambda>)r   r   get_typerJ   rW   r   rZ   rO   r   rO   r   rZ     s    

zCompletion.typec                 C   s   | j S )ao  
        Returns the length of the prefix being completed.
        For example, completing ``isinstance``::

            isinstan# <-- Cursor is here

        would return 8, because len('isinstan') == 8.

        Assuming the following function definition::

            def foo(param=0):
                pass

        completing ``foo(par`` would return 3.
        )r   rO   r   r   r   get_completion_prefix_length  s    z'Completion.get_completion_prefix_lengthc                 C   s   dt | j| j f S )Nz<%s: %s>)rZ   r   rJ   rW   rO   r   r   r   r     s    zCompletion.__repr__)N)FT)r   r   r   r   rM   r   r   r   r   ru   rp   rq   r   rZ   r   r   __classcell__r   r   r   r   r   _  s     

		r   c                       sL   e Zd ZdZ fddZedd Zdd Zdd	 Zd
d Z	dd Z
  ZS )r$   z{
    *Name* objects are returned from many different APIs including
    :meth:`.Script.goto` or :meth:`.Script.infer`.
    c                    s   t  || d S rH   )r   rM   )rL   r(   r_   r   r   r   rM     s    zName.__init__c                    s,    j  }tt fdd|D dd dS )zg
        List sub-definitions (e.g., methods in class).

        :rtype: list of :class:`Name`
        c                 3   s   | ]}t  j|V  qd S rH   )r/   rI   )r!   drO   r   r   rG     r   z%Name.defined_names.<locals>.<genexpr>c                 S   s   | j jp
dS r   rd   r   r   r   r   r     r   z$Name.defined_names.<locals>.<lambda>r   )rJ   r\   r   r   )rL   Zdefsr   rO   r   r/     s
    
zName.defined_namesc                 C   s    | j jdu rdS | j j S dS )z
        Returns True, if defined as a name in a statement, function or class.
        Returns False, if it's a reference to such a definition.
        NT)rJ   rX   r[   rO   r   r   r   r[     s    zName.is_definitionc                 C   s4   | j j|j jko2| j|jko2| j|jko2| j|jkS rH   )rJ   r   rV   r"   rI   rL   otherr   r   r   __eq__  s    


zName.__eq__c                 C   s   |  | S rH   )r   r   r   r   r   __ne__  s    zName.__ne__c                 C   s   t | jj| j| j| jfS rH   )hashrJ   r   rV   r"   rI   rO   r   r   r   __hash__  s    zName.__hash__)r   r   r   r   rM   r   r/   r[   r   r   r   r   r   r   r   r   r$     s   

r$   c                       s4   e Zd ZdZ fddZedd Zdd Z  ZS )r   zU
    These signatures are returned by :meth:`BaseName.get_signatures`
    calls.
    c                    s   t  ||j || _d S rH   )r   rM   r"   
_signature)rL   r(   rx   r   r   r   rM     s    zBaseSignature.__init__c                    s    fdd j jddD S )z
        Returns definitions for all parameters that a signature defines.
        This includes stuff like ``*args`` and ``**kwargs``.

        :rtype: list of :class:`.ParamName`
        c                    s   g | ]}t  j|qS r   )	ParamNamerI   r%   rO   r   r   r#   *  s   z(BaseSignature.params.<locals>.<listcomp>TZresolve_stars)r   get_param_namesrO   r   rO   r   params"  s    
zBaseSignature.paramsc                 C   s
   | j  S )z
        Returns a text representation of the signature. This could for example
        look like ``foo(bar, baz: int, **kwargs)``.

        :rtype: str
        )r   rw   rO   r   r   r   rw   -  s    zBaseSignature.to_string)	r   r   r   r   rM   r   r   rw   r   r   r   r   r   r     s
   

r   c                       s@   e Zd ZdZ fddZedd Zedd Zdd	 Z  Z	S )
	Signaturez\
    A full signature object is the return value of
    :meth:`.Script.get_signatures`.
    c                    s   t  || || _|| _d S rH   )r   rM   _call_detailsr   )rL   r(   rx   Zcall_detailsr   r   r   rM   <  s    zSignature.__init__c                 C   s   | j | jjddS )z
        Returns the param index of the current cursor position.
        Returns None if the index cannot be found in the curent call.

        :rtype: int
        Tr   )r   Zcalculate_indexr   r   rO   r   r   r   r   A  s    zSignature.indexc                 C   s
   | j jjS )z
        Returns a line/column tuple of the bracket that is responsible for the
        last function call. The first line is 1 and the first column 0.

        :rtype: int, int
        )r   Zbracket_leafr   rO   r   r   r   bracket_startM  s    zSignature.bracket_startc                 C   s   dt | j| j| j f S )Nz<%s: index=%r %s>)rZ   r   r   r   rw   rO   r   r   r   r   W  s
    zSignature.__repr__)
r   r   r   r   rM   r   r   r   r   r   r   r   r   r   r   7  s   

	r   c                   @   s0   e Zd Zdd Zdd Zdd Zedd Zd	S )
r   c                 C   s   t | j S )zu
        Returns default values like the ``1`` of ``def foo(x=1):``.

        :rtype: list of :class:`.Name`
        )r2   rJ   infer_defaultrO   r   r   r   r   `  s    zParamName.infer_defaultc                 K   s   t | jjf ddi|S )z
        :param execute_annotation: Default True; If False, values are not
            executed and classes are returned instead of instances.
        :rtype: list of :class:`.Name`
        Zignore_starsT)r2   rJ   infer_annotation)rL   kwargsr   r   r   r   h  s    zParamName.infer_annotationc                 C   s
   | j  S )zz
        Returns a simple representation of a param, like
        ``f: Callable[..., Any]``.

        :rtype: str
        )rJ   rw   rO   r   r   r   rw   p  s    zParamName.to_stringc                 C   s
   | j  S )z
        Returns an enum instance of :mod:`inspect`'s ``Parameter`` enum.

        :rtype: :py:attr:`inspect.Parameter.kind`
        )rJ   Zget_kindrO   r   r   r   kindy  s    zParamName.kindN)r   r   r   r   r   rw   r   r   r   r   r   r   r   _  s
   	r   )+r   r   pathlibr   typingr   Z
parso.treer   Zjedir   r   Zjedi.inference.utilsr   Z
jedi.cacher   Zjedi.inference.compiled.mixedr	   Zjedi.inference.namesr
   r   Z!jedi.inference.gradual.stub_valuer   Z!jedi.inference.gradual.conversionr   r   Zjedi.inference.base_valuer   r   Zjedi.api.keywordsr   Zjedi.apir   Zjedi.api.helpersr   r    r/   r2   r3   r   r$   r   r   r   r   r   r   r   <module>   s<       ' ,(