o
    tBh#                     @  sz  U d 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 ddlmZ dd	lmZmZmZmZmZmZmZmZ dd
lmZ ddlmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* dZ+de,d< eG dd dZ-eG dd de-Z.d;ddZ/d<dd Z0G d!d" d"e	Z1d#d#d$d%d=d2d3Z2d#d#d$d%d=d4d5Z3G d6d7 d7ee4 Z5d>d9d:Z6d$S )?z@Shared definitions used by different parts of semantic analysis.    )annotations)abstractmethod)Callable)FinalProtocol)trait)join)	ErrorCode)Context
ExpressionFuncDefNode
SymbolNodeSymbolTableSymbolTableNodeTypeInfo)TypeVarLikeScope)	TypeQuery)TPDICT_FB_NAMESFunctionLikeInstance
ParametersParamSpecFlavorParamSpecTypePlaceholderType
ProperType	TupleTypeType	TypeVarIdTypeVarLikeTypeget_proper_type   r   PRIORITY_FALLBACKSc                   @  s   e Zd ZdZe	d2d3ddZed4ddZed5ddZe	d2dddd6ddZeddd7ddZ	ed8dd Z
ed9d:d$d%Zed;d'd(Zeed<d)d*Zed=d,d-Zeed<d.d/Zed<d0d1ZdS )>SemanticAnalyzerCoreInterfacezA core abstract interface to generic semantic analyzer functionality.

    This is implemented by both semantic analyzer passes 2 and 3.
    Fnamestrctxr
   suppress_errorsboolreturnSymbolTableNode | Nonec                 C     t NNotImplementedErrorselfr$   r&   r'    r1   j/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/semanal_shared.pylookup_qualified7      z.SemanticAnalyzerCoreInterface.lookup_qualifiedr   c                 C  r+   r,   r-   r0   r$   r1   r1   r2   lookup_fully_qualified=      z4SemanticAnalyzerCoreInterface.lookup_fully_qualifiedc                 C  r+   r,   r-   r5   r1   r1   r2   lookup_fully_qualified_or_noneA   r7   z<SemanticAnalyzerCoreInterface.lookup_fully_qualified_or_noneN)blockercodemsgseriousr9   r:   ErrorCode | NoneNonec                C  r+   r,   r-   )r0   r;   r&   r<   r9   r:   r1   r1   r2   failE   s   
z"SemanticAnalyzerCoreInterface.fail)r:   c                C  r+   r,   r-   )r0   r;   r&   r:   r1   r1   r2   noteQ   r7   z"SemanticAnalyzerCoreInterface.notec                 C  r+   r,   r-   r0   r1   r1   r2   record_incomplete_refU   r7   z3SemanticAnalyzerCoreInterface.record_incomplete_refdebug_contextContext | Noneforce_progressc                 C  r+   r,   r-   )r0   rC   rE   r1   r1   r2   deferY   r7   z#SemanticAnalyzerCoreInterface.deferfullnamec                 C  r+   )zDIs a module or class namespace potentially missing some definitions?r-   )r0   rG   r1   r1   r2   is_incomplete_namespace]      z5SemanticAnalyzerCoreInterface.is_incomplete_namespacec                 C  r+   )z1Is this the final iteration of semantic analysis?r-   rA   r1   r1   r2   final_iterationb   r4   z-SemanticAnalyzerCoreInterface.final_iterationflagc                 C  r+   )z+Is the specific __future__ feature importedr-   )r0   rK   r1   r1   r2   is_future_flag_seth   rI   z0SemanticAnalyzerCoreInterface.is_future_flag_setc                 C  r+   r,   r-   rA   r1   r1   r2   is_stub_filem   rI   z*SemanticAnalyzerCoreInterface.is_stub_filec                 C  r+   r,   r-   rA   r1   r1   r2   is_func_scoper   r7   z+SemanticAnalyzerCoreInterface.is_func_scopeFr$   r%   r&   r
   r'   r(   r)   r*   )r$   r%   r)   r   )r$   r%   r)   r*   )r;   r%   r&   r
   r<   r(   r9   r(   r:   r=   r)   r>   )r;   r%   r&   r
   r:   r=   r)   r>   r)   r>   )NF)rC   rD   rE   r(   r)   r>   )rG   r%   r)   r(   r)   r(   )rK   r%   r)   r(   )__name__
__module____qualname____doc__r   r3   r6   r8   r?   r@   rB   rF   rH   propertyrJ   rL   rM   rN   r1   r1   r1   r2   r#   0   sB    r#   c                   @  s  e Zd ZU dZded< e	dUdVddZedWdXddZedWdYddZedZddZ	edddddddd[d)d*Z
ed\d.d/Zed]d4d5Zed^d9d:Zed_d=d>Zed`d@dAZe			dadbdGdHZedcdIdJZedddNdOZededQdRZeedfdSdTZdS )gSemanticAnalyzerInterfacezA limited abstract interface to some generic semantic analyzer pass 2 functionality.

    We use this interface for various reasons:

    * Looser coupling
    * Cleaner import graph
    * Less need to pass around callback functions
    r   
tvar_scopeFr$   r%   r&   r
   r'   r(   r)   r*   c                 C  r+   r,   r-   r/   r1   r1   r2   lookup   r4   z SemanticAnalyzerInterface.lookupNrG   argslist[Type] | Noner   c                 C  r+   r,   r-   r0   rG   r[   r1   r1   r2   
named_type   r7   z$SemanticAnalyzerInterface.named_typeInstance | Nonec                 C  r+   r,   r-   r]   r1   r1   r2   named_type_or_none   r7   z,SemanticAnalyzerInterface.named_type_or_nonenoder   r>   c                 C  r+   r,   r-   )r0   ra   r1   r1   r2   accept   r7   z SemanticAnalyzerInterface.acceptT)rY   allow_tuple_literalallow_unbound_tvarsallow_requiredallow_placeholderreport_invalid_typestr   TypeVarLikeScope | Nonerc   rd   re   rf   rg   Type | Nonec                C  r+   r,   r-   )r0   rh   rY   rc   rd   re   rf   rg   r1   r1   r2   	anal_type   s   z#SemanticAnalyzerInterface.anal_type
type_exprslist[Expression]list[TypeVarLikeType]c                 C  r+   r,   r-   )r0   rl   r1   r1   r2   get_and_bind_all_tvars   r7   z0SemanticAnalyzerInterface.get_and_bind_all_tvarsbasetype_or_fallbacklineintr   c                 C  r+   r,   r-   )r0   r$   rp   rq   r1   r1   r2   basic_new_typeinfo   r7   z,SemanticAnalyzerInterface.basic_new_typeinfopriorityfnCallable[[], None]c                 C  r+   r,   r-   )r0   rt   ru   r1   r1   r2   schedule_patch   r7   z(SemanticAnalyzerInterface.schedule_patchstnoder   c                 C  r+   )z%Add node to the current symbol table.r-   )r0   r$   rx   r1   r1   r2   add_symbol_table_node   rI   z/SemanticAnalyzerInterface.add_symbol_table_noder   c                 C  r+   )z^Get currently active symbol table.

        May be module, class, or local namespace.
        r-   rA   r1   r1   r2   current_symbol_table   s   z.SemanticAnalyzerInterface.current_symbol_tabler   contextmodule_publicmodule_hidden	can_deferc                 C  r+   )z'Add symbol to the current symbol table.r-   )r0   r$   ra   r{   r|   r}   r~   r1   r1   r2   
add_symbol   s   z$SemanticAnalyzerInterface.add_symbolc                 C  r+   )a  Add symbol to the current symbol table, skipping locals.

        This is used to store symbol nodes in a symbol table that
        is going to be serialized (local namespaces are not serialized).
        See implementation docstring for more details.
        r-   )r0   r$   ra   r1   r1   r2   add_symbol_skip_local   s   z/SemanticAnalyzerInterface.add_symbol_skip_localexprr   bool | Nonec                 C  r+   r,   r-   )r0   r   r1   r1   r2   
parse_bool   r7   z$SemanticAnalyzerInterface.parse_boolnc                 C  r+   r,   r-   )r0   r   r1   r1   r2   qualified_name   r7   z(SemanticAnalyzerInterface.qualified_namec                 C  r+   r,   r-   rA   r1   r1   r2   is_typeshed_stub_file   rI   z/SemanticAnalyzerInterface.is_typeshed_stub_filerO   rP   r,   )rG   r%   r[   r\   r)   r   )rG   r%   r[   r\   r)   r_   )ra   r   r)   r>   )rh   r   rY   ri   rc   r(   rd   r(   re   r(   rf   r(   rg   r(   r)   rj   )rl   rm   r)   rn   )r$   r%   rp   r   rq   rr   r)   r   )rt   rr   ru   rv   r)   r>   )r$   r%   rx   r   r)   r(   )r)   r   )TFT)r$   r%   ra   r   r{   r
   r|   r(   r}   r(   r~   r(   r)   r(   )r$   r%   ra   r   r)   r>   )r   r   r)   r   )r   r%   r)   r%   rR   )rS   rT   rU   rV   __annotations__r   rZ   r^   r`   rb   rk   ro   rs   rw   ry   rz   r   r   r   r   rW   r   r1   r1   r1   r2   rX   w   sX   
 		rX   sigr   fdefr   r)   r   c                 C  sX   t | } t| tr*|jr$|jjtv rd}n|jj}| |j d| S | |jS | S )N	TypedDictz of )r    
isinstancer   inforG   r   r$   	with_name)r   r   
class_namer1   r1   r2   set_callable_name   s   
r   typr   r>   c                 C  s<   | j }|jjdksJ tt| jf|jdd  |_dS )a  Calculate a precise item type for the fallback of a tuple type.

    This must be called only after the main semantic analysis pass, since joins
    aren't available before that.

    Note that there is an apparent chicken and egg problem with respect
    to verifying type arguments against bounds. Verifying bounds might
    require fallbacks, but we might use the bounds to calculate the
    fallbacks. In practice this is not a problem, since the worst that
    can happen is that we have invalid type argument values, and these
    can happen in later stages as well (they will generate errors, but
    we don't prevent their existence).
    builtins.tupler!   N)partial_fallbacktyperG   r   join_type_listlistitemsr[   )r   fallbackr1   r1   r2   calculate_tuple_fallback   s   &r   c                   @  s   e Zd Zd
ddd	ZdS )_NamedTypeCallbackNfully_qualified_namer%   r[   r\   r)   r   c                 C  s   d S r,   r1   )r0   r   r[   r1   r1   r2   __call__     z_NamedTypeCallback.__call__r,   )r   r%   r[   r\   r)   r   )rS   rT   rU   r   r1   r1   r1   r2   r     s    r   N)rq   columnprefixr$   r%   rG   idTypeVarId | intnamed_type_funcrq   rr   r   r   Parameters | Noner   c             
   C  s&   t | ||tj|d|dg|||dS )Nr   builtins.objectflavorupper_boundrq   r   r   )r   r   ARGSr$   rG   r   r   rq   r   r   r1   r1   r2   paramspec_args
  s   
r   c             
   C  s,   t | ||tj|d|d|dg|||dS )Nzbuiltins.dictzbuiltins.strr   r   )r   r   KWARGSr   r1   r1   r2   paramspec_kwargs   s   
r   c                      s(   e Zd Zd
 fddZddd	Z  ZS )HasPlaceholdersr)   r>   c                   s   t  t d S r,   )super__init__anyrA   	__class__r1   r2   r   9  s   zHasPlaceholders.__init__rh   r   r(   c                 C  s   dS )NTr1   )r0   rh   r1   r1   r2   visit_placeholder_type<  r   z&HasPlaceholders.visit_placeholder_typerQ   )rh   r   r)   r(   )rS   rT   rU   r   r   __classcell__r1   r1   r   r2   r   8  s    r   r(   c                 C  s   |  t S )z=Check if a type contains any placeholder types (recursively).)rb   r   )r   r1   r1   r2   has_placeholder@  s   r   )r   r   r   r   r)   r   )r   r   r)   r>   )r$   r%   rG   r%   r   r   r   r   rq   rr   r   rr   r   r   r)   r   )r   r   r)   r(   )7rV   
__future__r   abcr   typingr   typing_extensionsr   r   mypy_extensionsr   mypyr   mypy.errorcodesr	   
mypy.nodesr
   r   r   r   r   r   r   r   mypy.tvar_scoper   mypy.type_visitorr   
mypy.typesr   r   r   r   r   r   r   r   r   r   r   r   r    r"   r   r#   rX   r   r   r   r   r   r(   r   r   r1   r1   r1   r2   <module>   s<    (
<F
j
