
    X-Phx                   L   U d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZmZmZmZmZmZ ddlmZmZ ddlZddlmZ dd	lmZmZm Z m!Z!m"Z"m#Z#m$Z$ dd
l%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z: ddl;m<Z<m=Z=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZDmEZE ddlFmGZG ddlHmIZImJZJ ddlKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZ ddlmZ ddlmZ ddlmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dd lmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dd!lmZmZmZmZ dd"lmZ dd#lmZ dd$lmZ dd%lmZ eeeeUeeeeee         e_e_g
df         Zd&ed'<   d(Zd)ed*<   g d+Zd)ed,<   h d-Zd)ed.<    G d/ d0e          Zdd5Zdd9Z G d: d;e          Zej         G d< d=ej                              Zej         Zd)ed><   ej        Zd)ed?<   ej        Zd)ed@<    G dA dBee         e*          ZdddEZ G dF dGe$j                  Z	ddHZ
ddIZddJZddQZddUZ G dV dWe$j                  ZddYZ G dZ d[e$j                  Zdd\Z G d] d^e$j                  ZddaZddiZddkZddoZddrZdduZddvZddxZdd{Zdd}ZddZdS )zGExpression type checker. This file is conceptually part of TypeChecker.    )annotationsN)defaultdict)IterableIteratorSequence)contextmanager)CallableClassVarFinalOptionalcastoverload)	TypeAliasassert_never)	applytype	erasetypejoinmessage_registrynodes	operatorstypes)ArgTypeExpandermap_actuals_to_formalsmap_formals_to_actuals)ExpressionCheckerSharedApi)analyze_member_access)StringFormatterChecker)
erase_type!remove_instance_last_known_valuesreplace_meta_vars)ErrorWatcherreport_internal_error)expand_typeexpand_type_by_instancefreshen_all_functions_type_varsfreshen_function_type_vars)ArgumentInferContextinfer_function_type_argumentsinfer_type_arguments)literal)map_instance_to_supertype)is_overlapping_typesnarrow_declared_type)ErrorMessage)MessageBuilderformat_type)B	ARG_NAMEDARG_POSARG_STAR	ARG_STAR2IMPLICITLY_ABSTRACTLAMBDA_NAMELITERAL_TYPEREVEAL_LOCALSREVEAL_TYPEArgKindAssertTypeExprAssignmentExpr	AwaitExpr	BytesExprCallExprCastExprComparisonExprComplexExprConditionalExprContext	DecoratorDictExprDictionaryComprehensionEllipsisExprEnumCallExpr
Expression	FloatExprFuncDefGeneratorExpr	IndexExprIntExpr
LambdaExprListComprehensionListExpr
MemberExprMypyFileNamedTupleExprNameExprNewTypeExprOpExprOverloadedFuncDefParamSpecExprPlaceholderNodePromoteExprRefExpr
RevealExprSetComprehensionSetExpr	SliceExprStarExprStrExpr	SuperExpr
SymbolNodeTempNode	TupleExprr   TypeAliasExprTypeApplicationTypedDictExprTypeInfoTypeVarExprTypeVarTupleExpr	UnaryExprVar	YieldExprYieldFromExpr)PRECISE_TUPLE_TYPES)FunctionContextFunctionSigContextMethodContextMethodSigContextPlugin)
ENUM_BASES)state)find_memberis_equivalentis_same_type
is_subtypenon_method_protocol_membershas_await_expression)check_for_explicit_anyfix_instancehas_any_from_unimported_typeinstantiate_type_aliasmake_optional_typeset_any_tvarsvalidate_instance)	bind_selfcallable_typecustom_special_methoderase_to_union_or_bound
false_onlyfixup_partial_typefreeze_all_type_varsfunction_typeget_all_type_varsget_type_varsis_literal_type_likemake_simplified_unionsimple_literal_type	true_onlytry_expanding_sum_type_to_uniontry_getting_str_literalstuple_fallbacktype_object_type)(LITERAL_TYPE_NAMESTUPLE_LIKE_INSTANCE_NAMESAnyTypeCallableTypeDeletedType
ErasedType
ExtraAttrsFunctionLikeInstanceLiteralTypeLiteralValueNoneType
Overloaded
ParametersParamSpecFlavorParamSpecTypePartialType
ProperType	TupleTypeTypeTypeAliasTypeTypedDictType	TypeOfAnyTypeType	TypeVarIdTypeVarTupleTypeTypeVarTypeUnboundTypeUninhabitedType	UnionType
UnpackTypefind_unpack_in_listflatten_nested_tuplesflatten_nested_unionsget_proper_typeget_proper_typeshas_recursive_typeshas_type_varsis_named_instancesplit_with_prefix_and_suffix)is_generic_instanceis_overlapping_noneis_self_type_likeremove_optional)
type_state)fill_typevars)split_module_names)ExpressionVisitor
_TypeAlias
ArgChecker   r   
MAX_UNIONS)builtins.setzbuiltins.frozensetztyping.KeysViewztyping.ItemsViewzbuiltins._dict_keyszbuiltins._dict_itemsz_collections_abc.dict_keysz_collections_abc.dict_itemsOVERLAPPING_TYPES_ALLOWLIST>   builtins.memoryviewbuiltins.bytesbuiltins.bytearrayOVERLAPPING_BYTES_ALLOWLISTc                      e Zd ZdZdS )TooManyUnionszyIndicates that we need to stop splitting unions in an attempt
    to match an overload in order to save performance.
    N__name__
__module____qualname____doc__     N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/checkexpr.pyr   r      s           r   r   tr   returnboolc                    t          | t                    r	| j        rdS t          |           } t          | t                    p2t          | t
                    ot          d | j        D                       S )NFc              3  4   K   | ]}t          |          V  d S N)allow_fast_container_literal.0its     r   	<genexpr>z/allow_fast_container_literal.<locals>.<genexpr>   s+      (\(\b)Eb)I)I(\(\(\(\(\(\r   )
isinstancer   is_recursiver   r   r   allitemsr   s    r   r   r      ss    !]##  uAa"" 1i  \S(\(\TUT[(\(\(\%\%\r   exprr]   set[str]c                T   t                      }t          | j        t                    s| j        rwt          | j        t                    r!| j        r|                    | j                   t          | t                    rt          | j        t                    o| j        j        }t          | j        t                    r-|
                    t          | j        j                             n?d| j        v r6|s4|                    | j                            dd          d                    nzt          | t                    r#t          | j        t                     r| j        } n nBt#          dt%          |                      t          | j        t                    o| j        w|S )zRecursively extracts all module references from a reference expression.

    Note that currently, the only two subclasses of RefExpr are NameExpr and
    MemberExpr..   r   zUnknown RefExpr subclass: )setr   noderT   fullnameaddrV   ro   is_suppressed_importrk   updater   module_namersplitrS   r   r]   AssertionErrortype)r   outputr   s      r   extract_refexpr_namesr      s|   
 uuF
TY
)
) LT] Ldi** 	&t} 	& JJt}%%%dH%% 	L#-di#=#=#`$)B` $)X.. <01FGGHHHH%%.B%

4=//Q77:;;;j)) 	L$)W-- y !Jd4jj!J!JKKK- TY
)
) LT] L. Mr   c                      e Zd ZdZdS )FinishedzDRaised if we can terminate overload argument check early (no match).Nr   r   r   r   r   r     s        NNNNr   r   c                      e Zd ZdZdZdZdZdS )
UseReversezCUsed in `visit_op_expr` to enable or disable reverse method checks.r   r      N)r   r   r   r   DEFAULTALWAYSNEVERr   r   r   r  r    s#        MMGFEEEr   r  USE_REVERSE_DEFAULTUSE_REVERSE_ALWAYSUSE_REVERSE_NEVERc                     e Zd ZU dZded<   ded<   ded<   ded	<   d
ed<   ded<   ddZddZddZdddZdd!Z	dd%Z
ddd(Zdd+Zddd,Zdd-Zdd2Zdd3Zdd6Zdd7Zdd8ZddCZddGZddMZddPZddRZddSZddWZddXZddYZdd]Zd^gd_d`gdaZdbedc<   dddegidfdggidfdggidfdhdegidiZdjedk<   ddlZ ddoZ!ddrZ"ddyZ#dd}Z$ddZ%ddZ&	 	 dǐddZ'ddZ(ddZ)	 dːddZ*ddZ+	 	 	 	 	 dΐddZ,ddZ-ddZ.ddZ/ddZ0ddZ1ddZ2ddZ3ddZ4ddZ5ddZ6ddZ7ddZ8	 	 dǐddZ9ddZ:ddZ;	 	 dǐddZ<ddĄZ=ddńZ>ddȄZ?ddʄZ@dd˄ZAdd̄ZB	 dddфZCdd҄ZDeEdd؄            ZFdd܄ZGdd݄ZH	 ddd߄ZIddZJddZKdddZL	 dːddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWddZXdd ZYddZZddddddZ[	 dːdd
Z\	 dːd dZ]ddZ^ddZ_	 dddZ`ddZaddZbddZcddZdddZeddZf	 dːdd!Zgd	d"Zhd
d#Zidd&Zjdd)Zkdd*Zldd+Zm	 ddd/Zndd1Zodd3Zpdd5Zqdd7Zrdd8Zsdd;Ztdd>Zudd?ddBZvddDZwddFZxddHZyddJZzddMZ{ddOZ|ddQZ}ddRZ~d dTZd!dVZd"dWZd#dZZd$d\Zd%d^Zd&d`Zd'dbZd(dcZd)deZd*dgZd+diZ	 dːd,doZd-dqZd.dsZdd/duZ	 	 d0d1dyZ	 	 	 	 d2d3d|Zd4d~Zd5dZddZddZd6dZd7dZd8dZdd9dZ	 dd:dZdd;dZd<dZd=dZd>dZd?dZd@dZdAdZdBdZdCdZdDdZdEdZd5dZd5dZedFd            ZedGd            Z	 ddGdZdHdZdHdZdS (I  ExpressionCheckerz^Expression type checker.

    This class works closely together with checker.TypeChecker.
    mypy.checker.TypeCheckerchkr/   msgzlist[Type | None]type_contextzdict[Expression, ProperType]resolved_typer   strfrm_checkerrw   pluginper_line_checking_time_nsdict[int, int]r   Nonec                "   || _         || _        || _        || _        |j        j        du| _        d| _        dg| _        i | _	        t          | j         | j                  | _        i | _        d| _        | j         j        j         t          _        dS )z%Construct an expression type checker.NF)r  r  r  r  optionsline_checking_statscollect_line_checking_statsin_expressionr  type_overridesr   r  r  	is_calleeold_type_inferencer   infer_polymorphic)selfr  r  r  r  s        r   __init__zExpressionChecker.__init__?  s     )B&+.;+JRV+V( #!F 794TXtxHH +/8+;+N'N
$$$r   c                    i | _         d S r   )r  r  s    r   resetzExpressionChecker.reseta  s    r   erV   r   c                    | j         j                            t          |                     |                     |          }|                     ||          }| j                             |j        |           |S )z_Type check a name expression.

        It can be of any kind: local, member or global.
        )r  module_refsr   r   analyze_ref_exprnarrow_type_from_bindercheck_deprecatedr   )r  r$  resultnarroweds       r   visit_name_exprz!ExpressionChecker.visit_name_exprd  sm    
 	##$9!$<$<===&&q))//6::!!!&!,,,r   Fr]   lvaluer   c                   d }|j         }t          |t                    r |j        rt	          t
          j                  S t          |t                    rJ|                     ||          }t          |t                    r| j
                            ||||          }nt          |t                    r%t          ||                     d                    }nt          |t                    rk|j        [| j
                                        r'|j        r | j
                            |j        |           t	          t
          j                  }n&|j        }nt          |t,                    r|j        r|                     |          }n<|j        dk    rt5          t7                                }nt9          || j                  }t          |t:                    r<t          |j        t>                    r"|j         |j        _         |j!        |j        _!        tE          | j#        d                   rtI          j%        |          }n.t          |tL                    r| '                    |          }nt          |tP                    r|                     |j)        |          }nt          |tT                    r | +                    |||j,        p|          }nt          |tZ                    r|                     d          S t          |t\          t^          f          r| 0                                }nAt          |tb                    rJ d|j        d            t	          t
          j                  }|J |S )	Nbuiltins.functionztypes.NoneTypectxalias_definitionztyping.TypeVarFzPlaceholderNode z leaked to checker)2r   r   rV   is_special_formr   r   special_formro   analyze_var_refr   r  handle_partial_var_typerL   r   
named_typerY   r   in_checked_functionr   handle_cannot_determine_typename
from_errorrk   typeddict_typetypeddict_callabler   r   r   r   r   ret_typer   linecolumnis_type_type_contextr  r   erase_typevarsrT   module_typerE   varr   alias_type_in_runtime_contextis_alias_rvaluerl   rZ   rm   object_typer[   )r  r$  r-  r*  r   s        r   r'  z"ExpressionChecker.analyze_ref_expro  s<   "va"" 	3q'8 	391222dC   9	3))$22F&+.. S99&&$PQRRg&& 4	3"49L)M)MNNFF/00 1	3y 8//11 Hdj HH99$)QGGG !566h'' *	3" A0066"222!(**--)$@@&,// 2J5 5 2
 ()v$)*&#D$5b$9:: : #1&99h'' 	3%%d++FFi(( 	3))$(A66FFi(( 	3 77!a.?.I6 8  FF k** 		3??#3444}.>?@@ 	3%%''FF$00 UTTTTTTTT Y122F!!!r   rE  ro   contextrD   c                   |j         rt          |j                   }t          |t                    rj|j        dk    r|                     d          S |                                 r|j        |j        S |j        dv r| 	                    |j        dk    d          S |j         S |j
        s9| j                                        r | j                            |j        |           t          t          j                  S )Nz
typing.Anytyping._SpecialForm>   TrueFalserL  builtins.bool)r   r   r   r   r   r8  is_literal_contextlast_known_valuer;  infer_literal_expr_typeis_readyr  r9  r:  r   r   r5  )r  rE  rI  var_types       r   r6  z!ExpressionChecker.analyze_var_ref  s    8 	3&sx00H(H-- ]<<//??+@AAA**,, 51J1V#44800077F8JO\\\8O< IDH$@$@$B$B I55chHHH91222r   r   rT   r   c                   	 |                      d          }n%# t          $ r |                      d          }Y nw xY wi }t                      }|j                                        D ]\  }}|j        st          |j        t                    r!|j        j	        r|
                    |           | j                            |          }|r|||<   jt          t          j                  ||<   t!          |||j                  |_        |S )Nztypes.ModuleTypebuiltins.object)r8  KeyErrorr   namesr   module_publicr   r   ro   is_finalr   r  determine_type_of_memberr   r   r5  r   r   extra_attrs)r  r   r*  module_attrs	immutabler;  ntyps           r   rD  zExpressionChecker.module_type  s   	8__%788FF 	8 	8 	8 __%677FFF		8
 EE	z'')) 	E 	EGD!? !&#&& $16? $d###(33A66C E%(T"" &-Y-C%D%DT""'iOOs    ::r?   allow_none_returnc                    |j         rat          |j         t                    r!|j         j        s|                     |           |                     |j         | j        d                   S |                     ||          S )zType check a call expression.r0  r`  )analyzedr   rU   is_typedvisit_call_expr_inneracceptr  )r  r$  r`  s      r   visit_call_exprz!ExpressionChecker.visit_call_expr  s{    : 	B!*n55 .aj>Q . **1---;;qz4+<R+@AAA))!?P)QQQr   baserJ   c                   t          |t                    sdS t          |j        t                    r|j        j        dS t          |j        t
                    o+t          t          |j        j                  t                    S )NFT)	r   r]   r   rk   r=  r   r   targetr   )r  rh  s     r   refers_to_typeddictz%ExpressionChecker.refers_to_typeddict  ss    $(( 	5di** 	ty/G/S4$)Y// 
JDI,--}5
 5
 	
r   c           	     d                          j                  s9t          j        t                    r                      j        j                  rt                               j        d                    }t          |t                    rTt          |j                  }t          |t                    sJ  
                    |j        j        j        |          S t          j        t                    rj        j        dv rt!          j                  dk    rt"          j                            j        d                   D ]`}d }t          |t                    r1	  j                            |j                  }n# t,          $ r Y nw xY wt/          |          r' j                            j        j        d           |rt          |j        t6                    rlt          |j        j                  }t          |t:                    r' j                            j        j        d           t          |t<                    r	t          |t                    r!t          |j        t@          tB          f          srt          |t                    rw|rut          |j        t6                    r[|j        j"        sOt          t          |j        j                  x}tF                    r|j$        s j        %                               t          |tL                    rt          |j        tN                    rf|j        j(        r( j                            j        j        d           .|j        j)        r& j                            j        j        d	           b *                               d }	t          j        tV                    rtY          j        j        j        j        j        j         fd
           fdt[          t!          j        j                            D             }
t          |
j        j        j        j         .                                 /                    d                    }	t                               j        |	dd                    }d }d }d t          j        tL                    r܉j        j0        pd t          j        j        t6                    r?t          j        j        j                  }t          |tb                    r|j2        j0        snt          j        tf                    rT j        4                    j        j5                  r0j        j        } j        6                    j        j5                  } j        j7        j8        r j        9                                rt          |t                    r||j:        ru|j        tv          k    re||J  <                    ||          r*t{          fd j        j7        j>        D                       s j        ?                    |            @                    |||          }t          j        tL                    r`t!          j                  dk    rHj        j0        dv r A                               j        j0        dk    r B                               t          j        tf                    r%j        j        dk    r C                               t          |          }t          |tF                    rt          |jE                  }t          |t                    r%|jG        s j        jH        I                                 |sht          |t<                    rS J                    j                  r9 j        j        K                    |           t;          t          jM                  S |S )NTr  )r   
issubclassr  r   LiteralAny	TypedDictNewTypec                D                         j        |                    S r   rf  args)ir$  r  s    r   <lambda>z9ExpressionChecker.visit_call_expr_inner.<locals>.<lambda>3  s    $++afQi00 r   c                ^    g | ])}t          j        fd |         D                       *S )c                P    g | ]"}                     j        |                   #S r   rt  )r   jr$  r  s     r   
<listcomp>zFExpressionChecker.visit_call_expr_inner.<locals>.<listcomp>.<listcomp>7  s+    $Y$Y$YT[[%;%;$Y$Y$Yr   )r   join_type_list)r   rv  r$  formal_to_actualr  s     r   r{  z;ExpressionChecker.visit_call_expr_inner.<locals>.<listcomp>6  sS        #$Y$Y$Y$Y$YEUVWEX$Y$Y$YZZ  r   r/  )r?  fallback)always_allow_anyr  c              3  T   K   | ]"}|k    p                     | d           V  #dS )r   N)
startswith)r   pr   s     r   r   z:ExpressionChecker.visit_call_expr_inner.<locals>.<genexpr>h  sT       ' ' A=!4!4WWW!=!=' ' ' ' ' 'r   )zbuiltins.isinstancebuiltins.issubclassr  format)Nrk  calleer   rN   rh  r   rf  r   r?  r   check_typeddict_call	arg_kinds	arg_namesru  rV   r;  lenmypycheckerflattenr  lookup_qualifiedrV  is_expr_literal_typer  cannot_use_function_with_typer   r   rj  r   r   rc  ri   rh   no_argsr   uses_pep604_syntaxtype_arguments_not_allowedr]   rk   r=  
is_newtypetry_infer_partial_typerP   r   rangerH  r8  r   r   r   rS   has_typer   lookup_typer  disallow_untyped_callsr9  implicitr6   method_fullnameanyuntyped_calls_excludeuntyped_function_call check_call_expr_with_callee_typecheck_runtime_protocol_testcheck_protocol_issubclasscheck_str_format_callr   r   r   	ambiguousbinderunreachablealways_returns_nonedoes_not_return_valuer   r<  )r  r$  r`  r>  r=  r_  r   rj  union_targetr  	arg_typescallee_typerH  memberr?  r}  r   s   ``             @@r   re  z'ExpressionChecker.visit_call_expr_inner  s   $$QX..	!(I..	 ((77	
 "1QXQU1V1V!W!W,l;; !01C1L!M!M!.-@@@@@00"AKafaI[   qx**)	\!===AFq  |++AF1I66 $\ $\c8,, #x88BB#    (,, H::18=)UVWWW !Jty)<< !,TY-=>>F!&'22 !>>qx}eUVWWW !&(33 ! sI..;"3</=1QRR; sH--	;
 ; #49i88; !I-; #?49CS3T3T#T<V_``; );; H77:::c7++ \
38X0N0N \x. \>>qx}k[\]]]], \>>qx}iYZ[[[##A&&&ah
++ 	5""00000        s18#56677  I (""))++)<==  L &KK,QUKVV
 

 ah(( 	B x(0DH!(-33 4()=>>fh// 4%{3H Bqx44B H%%ahm44B
 "h2218=AA H3	?,,..	? ;55	? $		?
  K//F$6"...//VDD ?3 ' ' ' ')?' ' ' $ $ ? ..{A>>>88Hk6
 
 ah(( 	2S[[A-=-=x $RRR00333x $999..q111ah
++ 	*0I0I&&q)))"8,,h	** 	=,X^<<Hh00 	*9K 	*HO'')))
 "	18X..	1 ((22	1
 HL..{A>>>9/000s   2F
FFc                X   t          |j        t                    sJ d}t          |j        j        t                    r|j        j        j        }n:| j                            |j        j                  rt          | j        	                    |j        j                            }t          |t                    r|j        j        r~t          |j        t                    rdt          |j        j        t                    rE|j        j        |j        j                 j        }t          |t"                    rt          |          }t%          |          }t          |t                    r!t          |j        t                    r|j        }|| j                            ||           dS dS )z>More precise type checking for str.format() calls on literals.N)r   r  rS   r   rc   valuer  r  r   r  r   r   is_enumrP  r   strrW  r   try_getting_literalr  r  )r  r$  format_valuer_  
value_typebase_typs         r   r  z'ExpressionChecker.check_str_format_call  so   !(J/////ahmW-- 	.8=.LLXqx}-- 	.!$("6"6qx}"E"EFFC3))6H$6 s3[AA6 s393??	6 !X^C,@,FGL
j$// 6)*55C*3//H(K00 .ZPS5T5T .'~#55aFFFFF $#r   rH  method_namer  
str | Nonec                   t          |          }t          |t                    r)|                                rt          |j                  }nt          |t
                    r|j        }d}t          |t                    r|j        j	        }nut          |t          t          f          r+|j        j                            |          }||j	        nd}n.t          |t                    rt          |          j        j	        }|r| d| S dS )zConvert a method name to a fully qualified name, based on the type of the object that
        it is invoked on. Return `None` if the name of `object_type` cannot be determined.
        Nr   )r   r   r   is_type_objr?  r   itemr   r   r   r   r   r~  get_containing_type_infor   r   )r  rH  r  	type_nameinfos        r   r  z!ExpressionChecker.method_fullname  s    &k22k<00 	+[5L5L5N5N 	+ *+*>??KKX.. 	+%*K	k8,, 	B#(1IIm[%ABB 	B',EEkRRD)-)9tIIY// 	B&{338AI 	//+///4r   c                ^   t          |t                    r|                     |j                  rdS t          |t                    r|j        t          | j                            |j                            }t          |t                    r|j
        }n^t          |t                    rG|                                r3t          |j                  }t          |t                    r|j
        }ndS dS |                    |j                  }|r|                     |j                  rdS dS )zPCheck if `node` refers to something explicitly annotated as only returning None.TNF)r   r]   defn_returns_noner   rS   r   r  r  r   r   r   r   r  r?  getr;  )r  r   r_  r  r?  syms         r   r  z%ExpressionChecker.always_returns_none  s   dG$$ 	%%di00 tdJ'' 	DI,=!$("6"6ty"A"ABBC#x(( 	xC.. 3??3D3D *3<88h11 !#=DD 5u((49%%C t--ch77 tur   defnSymbolNode | Nonec                    t          |t                    rFt          |j        t                    o+t          t	          |j        j                  t                    S t          |t                    r t           fd|j	        D                       S t          |t                    rt	          |j                  }|j        s>t          |t                    r)t          t	          |j                  t                    rdS t          |t                    r8|j                            d          }|r                     |j                  rdS dS )z'Check if `defn` can _only_ return None.c              3  B   K   | ]}                     |          V  d S r   )r  )r   r  r  s     r   r   z6ExpressionChecker.defn_returns_none.<locals>.<genexpr>  s1      KKt--d33KKKKKKr   T__call__F)r   rL   r   r   r   r?  r   rY   r   r   ro   is_inferredr   r  r  r   )r  r  r_  r  s   `   r   r  z#ExpressionChecker.defn_returns_none  s8   dG$$ 	di66 :	 233X< <  d-.. 	LKKKK
KKKKKKdC   	 !$),,C$sL11 s|<<hGG
 t#x((  hll:..  411#(;;  4ur   c                   t           j                            |j        d                   D ]}t	          | j                            |                    }t          |t                    rk|	                                rW|
                                j        r>|
                                j        s%| j                            t          j        |           d S Nr   )r  r  r  ru  r   r  r  r   r   r  type_objectis_protocolruntime_protocolfailr   RUNTIME_PROTOCOL_EXPECTED)r  r$  r   tps       r   r  z-ExpressionChecker.check_runtime_protocol_test  s    L((33 	M 	MD !5!5d!;!;<<B2|,,MNN$$M NN$$0M ((9	M .H!LLL	M 	Mr   c                   t           j                            |j        d                   D ]}t	          | j                            |                    }t          |t                    r|	                                ro|
                                j        rVt          |
                                          }|r3| j        j                            |
                                ||           d S r  )r  r  r  ru  r   r  r  r   r   r  r  r  r~   r  report_non_method_protocol)r  r$  r   r  attr_memberss        r   r  z+ExpressionChecker.check_protocol_issubclass  s    L((33 	_ 	_D !5!5d!;!;<<B"l++ _0@0@ _R^^EUEUEa _:2>>;K;KLL _HL;;BNN<L<Ll\]^^^	_ 	_r   r  r   r  list[ArgKind]r  Sequence[str | None]ru  list[Expression]orig_calleeType | Nonec                4   |rt          d |D                       rjt          d |D             |          }|                     ||          }||\  }	}
|                     ||	|||
          S t	          t
          j                  S t          |          dk    r|d         t          k    r|d         }t          |t                    r|                     ||j        ||          S t          |t                    r<t          |j        t                    r"|                     ||j        j        ||          S |s%|                     |i ||t                                S | j                            t$          j        |           t	          t
          j                  S )Nc              3  6   K   | ]}|t           t          fv V  d S r   )r1   r4   )r   aks     r   r   z9ExpressionChecker.check_typeddict_call.<locals>.<genexpr>  s,      IIy)44IIIIIIr   c                4    g | ]}|t          |          nd S r   )rc   )r   r^  s     r   r{  z:ExpressionChecker.check_typeddict_call.<locals>.<listcomp>  s&    SSSA'!***4SSSr   kwargsr  r   r   )r   zipvalidate_typeddict_kwargs check_typeddict_call_with_kwargsr   r   r<  r  r2   r   rF   check_typeddict_call_with_dictr   r?   rc  r   r  r  r   INVALID_TYPEDDICT_ARGS)r  r  r  r  ru  rI  r  r  r*  validated_kwargsalways_present_keys
unique_args               r   r  z&ExpressionChecker.check_typeddict_call  s     	1CIIyIIIII 	1 SSSSSUYZZF336&3QQF!8>5 "5<<,g{DW   9/000t99>>ilg55aJ*h// ::J,g{   *h// Jz?RT\4]4] ::J/5w    	b88Wk[^[`[`aaa&=wGGGy+,,,r   r  .Iterable[tuple[Expression | None, Expression]]3tuple[dict[str, list[Expression]], set[str]] | Nonec                   t          t                    }t                      }d }|D ]\  }}|r|                     |          }t	          ||          }	d }
|	rt          |	          dk    r|	d         }
|
8|p|}| j                            t          j	        |t          j                    d S |g||
<   |                    |
           |}|                     ||||          s d S | j        j        j        rM|Kg }|j        D ]$}||j        vr||vr|                    |           %|r| j                            ||           ||fS )Nr   r   code)r   listr   rf  r   r  r  r  r   $TYPEDDICT_KEY_MUST_BE_STRING_LITERALcodesLITERAL_REQr   validate_star_typeddict_itemr  extra_checksr   required_keysappendr  "non_required_keys_absent_with_star)r  r  r  r*  r  last_star_founditem_name_expritem_argkey_typevaluesliteral_valuekey_contextabsent_keyskeys                 r   r  z+ExpressionChecker.validate_typeddict_kwargs%  s    T""!ee(. 	  	 $NH  ;;~661.(KK $ .c&kkQ..$*1IM ("0"<HKHMM(M#". "   
  44
 .6JF=)'++M::::"*88ff.A     44  8( 
	Z_-HK| , ,f222s&7H7H&&s+++ Z
 ;;KYYY***r   r  r*  dict[str, list[Expression]]r  r   c                   t          |                     ||                    }g }t          |t                    r|g}nt          |t                    rt          |                                          D ]`}t          |t                    r|                    |           -|                     |          s| j	        
                    ||            dS an2|                     |          s| j	        
                    ||           dS t                      }|D ]}	||	j                                        z  }|D ]Њt          t	          j        fd|D                                 }
|
                    |           t#          fd|D                       rV|                               |         r2|         d         }t          |t                    s||
g|<   |
g|<   |
g|<   |                             |
           dS )zUpdate keys/expressions from a ** expression in TypedDict constructor.

        Note `result` and `always_present_keys` are updated in place. Return true if the
        expression `item_arg` may valid in `callee` TypedDict context.
        r  Fc                <    g | ]}|j         v |j                  S r   r   r   tdr  s     r   r{  zBExpressionChecker.validate_star_typeddict_item.<locals>.<listcomp>v  s(    %^%^%^cUWU]oobhsmooor   c              3  *   K   | ]}|j         v V  d S r   r  r  s     r   r   zAExpressionChecker.validate_star_typeddict_item.<locals>.<genexpr>y  s+      BBr3"**BBBBBBr   r   T)r   rf  r   r   r   r   relevant_itemsr  valid_unpack_fallback_itemr  %unsupported_target_for_star_typeddictr   r   keysrf   
make_unionset_liner   r   )r  r  r  r*  r  inferredpossible_tdsr  all_keysr   argfirstr  s               @r   r  z.ExpressionChecker.validate_star_typeddict_itemW  sJ    #4;;xf;#M#MNNh.. 	$:LL),, 		()@)@)B)BCC ! !dM22 ! ''----88>> !HBB4RRR 55!! 00:: 	H::8XNNN5 UU 	( 	(B'HH 	( 	(C$%^%^%^%^l%^%^%^__ C LL"""BBBB\BBBBB (#'',,,
 #; 	("3KNE%eX66 , (-cls'*es#&%F3KK s""3''''tr   r_  r   c                8   t          |t                    rdS t          |t                    r|j                            d          sdS t          || j                            d                    }t          d t          |j
                  D                       S )NTtyping.MappingFc              3  @   K   | ]}t          |t                    V  d S r   )r   r   r   as     r   r   z?ExpressionChecker.valid_unpack_fallback_item.<locals>.<genexpr>  s,      QQa:a))QQQQQQr   )r   r   r   r   has_baser+   r  lookup_typeinfor   r   ru  )r  r_  mappeds      r   r  z,ExpressionChecker.valid_unpack_fallback_item  s    c7## 	4#x(( 	0A0ABR0S0S 	5*30H0HIY0Z0Z[[QQ3CFK3P3PQQQQQQr   *list[tuple[Expression | None, Expression]]c                    |                      ||          }|]|\  }}|j        t          |                                          cxk    o)t          |j                                                  k    nc S dS )Nr  F)r  r  r   r  r   )r  r  r  rI  r*  r  _s          r   match_typeddict_call_with_dictz0ExpressionChecker.match_typeddict_call_with_dict  s     //vf/MM"(a'3/?/D/D/F/F+G+Gcccc3v|O`O`ObObKcKcccccc5r   c                    |                      ||          }||\  }}|                     |||||          S t          t          j                  S )Nr  )r  rI  r  r  )r  r  r   r   r<  )r  r  r  rI  r  r*  r  r  s           r   r  z0ExpressionChecker.check_typeddict_call_with_dict  sm     //vf/MM4:1188''$7 9    9/000r   r  rk   r   c           	        |j         J |j         j        }t          |t                    rt          |t                    sJ t          |j                                                  }t          j	        gt          |          z  }t          |j                                                  }t          |||||                     d          |j        j                  S )a  Construct a reasonable type for a TypedDict type in runtime context.

        If it appears as a callee, it will be special-cased anyway, e.g. it is
        also allowed to accept a single positional argument if it is a dict literal.

        Note it is not safe to move this to type_object_type() since it will crash
        on plugin-generated TypedDicts, that may not have the special_alias.
        Nbuiltins.type	variables)special_aliasrj  r   r   r   r  r   r  r:   r1   r  r  r   r8  r  	type_vars)r  r  rj  expected_typeskindsrW  s         r   r>  z$ExpressionChecker.typeddict_callable  s     !---#*&*--S*V]2S2SSSSfl113344"#c.&9&99V\&&(())OOO,,i)
 
 
 	
r   c           	        t          t          j                                                  fdj        D             t          j                                                  |                     d                    S )Nc                R    g | ]#}|j         v rt          j        nt          j        $S r   )r  r:   r1   ARG_NAMED_OPT)r   r;  r  s     r   r{  zEExpressionChecker.typeddict_callable_from_context.<locals>.<listcomp>  sA        &*V-A%A%A!!wG\  r   r  )r   r  r   r  r  r8  )r  r  s    `r   typeddict_callable_from_contextz1ExpressionChecker.typeddict_callable_from_context  s    $$&&''   "L   ""$$%%OOO,,	
 	
 		
r   c                |   |                                 j        r(j        z  }|r| j                            ||           j        |k    rj                                         k    sj                                         k    sO| j                            fdj                                         D             t                    |           j        |k    sM| j                            fdj                                         D             fd|D             |           j        k    rt          t          j                  S t          |          }t          |t                    r|}nFj        j        j         |                     j        j                  }n|                               }| j                                        5  | j                                        5  |                     |d |                                D             t2          j        gt7          |          z  |t          |                                           d d d           \  }}	d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |          }
t          |
t8                    s}
|
j                                        D ]b\  }}||v rY||         }|D ]N}| j                            |||t=          t>          j         j!        tD          j#                  d| d	d
           Oc|S )NrI  c                .    g | ]}|j         v s|v |S r   r  )r   r  actual_keysr  s     r   r{  zFExpressionChecker.check_typeddict_call_with_kwargs.<locals>.<listcomp>  s;     # # #&"666#:L:L :L:L:Lr   )expected_keysr*  rI  c                &    g | ]}|j         v |S r   r  r   r  r  s     r   r{  zFExpressionChecker.check_typeddict_call_with_kwargs.<locals>.<listcomp>  s-     # # # #cVEY>Y>Y>Y>Y>Yr   c                &    g | ]}|j         v |S r   r  r-  s     r   r{  zFExpressionChecker.check_typeddict_call_with_kwargs.<locals>.<listcomp>  s-     ! ! ! #cVEY>Y>Y>Y>Y>Yr   c                    g | ]
}|d          S r   r   )r   ru  s     r   r{  zFExpressionChecker.check_typeddict_call_with_kwargs.<locals>.<listcomp>  s    555Ta555r   r  zTypedDict item ""
expression)lvalue_typervaluerI  r  lvalue_namervalue_name)$r  to_be_mutatedreadonly_keysr  readonly_keys_mutatedr  r   unexpected_typeddict_keysr  r   r   r<  r   r   r   r~  r   r  r>  r&  filter_errorsr  local_type_mapcheck_callable_callr  r:   r1   r  r   check_simple_assignmentr.   r   INCOMPATIBLE_TYPESr  r  TYPEDDICT_ITEM)r  r  r  rI  r  r  assigned_readonly_keysinfer_calleeorig_ret_typer  r?  	item_nameitem_expected_typeitem_values
item_valuer*  s    `             @r   r  z2ExpressionChecker.check_typeddict_call_with_kwargs  s/    kkmm 	X%063G%G"% X../Ew.WWW $777K6<K\K\K^K^<^<^6<#4#4#6#66622# # # # ##)<#4#4#6#6# # #
 !%[ 1 1# 3 	 	 	 (,???22# # # #'-|'8'8':':# # #! ! ! !':! ! ! $ 3 	 	 	 #k11 y3444%k22k<00 	L&LL #1=#66v7KLL  $CCFKK X##%% 	 	tx'>'>'@'@ 	 	#77 65V]]__555"#c&kk1V[[]]##   M1	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 #=11(M22 	 H-5^-A-A-C-C 	 	)I)F""$Y/"- 
 
JH44$6) *(,?EEL`   %Dy$C$C$C$0 5 	 	 	 	 s7   J6A6I8,J8I<	<J?I<	 JJJr   rS   
Var | Nonec                   t          |j        t                    r0t          |j        j        t                    r|j        j        j        sdS | j        j                                        }|r|j	        |j
        vrdS |j
        |j	                 }t          |j        t                    r&t          |j        j        t                    r|j        S dS )zGet variable node for a partial self attribute.

        If the expression is not a self attribute, or attribute is not variable,
        or variable is not partial, return None.
        N)r   r   rV   r   ro   is_selfr  scopeenclosing_classr;  rW  r   r   )r  r   r  r  s       r   get_partial_self_varz&ExpressionChecker.get_partial_self_var;  s     ty(++	49>3//	 	&	 4x~--// 	ty
224j#ch$$ 	CHM;)O)O 	8Otr   r  r   discard)builtins.listr   zClassVar[dict[str, list[str]]]	item_argsextendrO  r   builtins.dictr   )rO  rR  zcollections.OrderedDictr   z)ClassVar[dict[str, dict[str, list[str]]]]container_argsc                   t          |j        t                    sdS |j        }t          |j        t                    rg|                     |j                  }|dS |\  }}|                     ||j        |          }|"||v r | j        	                    |||           dS dS dS t          |j        t                    r0t          |j        j        t                    r|j        j        dS |j        j        }|j        j        }|                     |          }|dS |\  }}t          |j                  }	|	|	j        dS |                     ||j        |          }
|
|                     |          }t$          j                            || j        j                  rV|	j        J |	j        j        }| j                            |||
g          }| j        	                    |||           dS dS dS dS dS )z-Try to make partial type precise from a call.N)r   r  rS   r   r]   get_partial_var&try_infer_partial_value_type_from_callr;  r  replace_partial_typerN   rh  rc  indexget_partial_instance_typer   r  rf  r  r  is_valid_inferred_typer  r   named_generic_type)r  r$  r  retrE  partial_typesr_  rh  rX  partial_typer  r  typenamenew_types                 r   r  z(ExpressionChecker.try_infer_partial_type]  s#   !(J// 	Ffk7++  	P&&v{33C{!$C==acRRC3-#7#7--c3FFFFF #7#7Y// 	PJv{?OQX4Y4Y 	P{#/;#DK%E&&t,,C{!$C4SX>>L#|'>'FDDQUXYYJ%;;u--<66xAQRR P',888+09H#x::8hPZE[\\HH11#xOOOOO-	P 	P 	P 	P &%P Pr   ref%tuple[Var, dict[Var, Context]] | Nonec                    |j         }|*t          |t                    r|                     |          }t          |t                    sd S | j                            |          }|d S ||fS r   )r   r   rS   rM  ro   r  find_partial_types)r  ra  rE  r]  s       r   rU  z!ExpressionChecker.get_partial_var  sq    h;:c:66;++C00C#s## 	433C88 4M!!r   
methodnameInstance | Nonec                     j         j        rdS t          |j                  }|dS |j        r|j        j        j        }n|j        J |j        j        }| j        v r| j        |         v ry|j        t          gk    rh 	                    |j
        d                   }t          j                            | j         j                  r j                             ||g          S n
| j        v r | j        |         v r|j        t          gk    rt#           	                    |j
        d                             }t%          |t&                    ro|j        j        }| j        |         |         v rMt)           fd|j
        D                       r- j                             |t+          |j
                            S n/t%          |t,                    r j                             |          S dS )zCTry to make partial type precise from a call such as 'x.append(y)'.Nr   c              3  l   K   | ].}t           j                            |j        j                  V  /d S r   )r  r  rZ  r  r  )r   	item_typer  s     r   r   zKExpressionChecker.try_infer_partial_value_type_from_call.<locals>.<genexpr>  sN        % ;;ItxGWXX     r   )r  current_node_deferredrY  r   r  r   rP  r  r2   rf  ru  r  r  rZ  r  r[  rS  r   r   r   r   r  r   r8  )	r  r$  re  rE  r^  r_  ri  arg_typearg_typenames	   `        r   rV  z8ExpressionChecker.try_infer_partial_value_type_from_call  s    8) 	40::4" 	2#.3<HH$000#(1H &&dnX666y((AF1I..I|229dh>NOO Jx228i[IIIJ +++d1(;;;y((&t{{16!9'='=>>H(H-- 	5'}54#6x#@#LLL    )1     Z  $x::8T(-EXEXYYYHg.. 5x**8444tr   r  
list[Type]Sequence[str | None] | Noner}  list[list[int]]r   c
                   t          |j                  }
d t          |
          D             }d t          |
          D             }d t          |
          D             }d t          |
          D             }t          |          D ]\  }}|D ]}||                             ||                    ||                             ||                    |r"||                             ||                    n||                             d           ||                             ||                    |M| j                            |          }|J  |t          |||j        ||j	        ||	| j
                            S | j                            |          }|J t          |          } |t          ||||j        ||j	        ||	| j
        	  	                  S )a  Use special case logic to infer the return type of a specific named function/method.

        Caller must ensure that a plugin hook exists. There are two different cases:

        - If object_type is None, the caller must ensure that a function hook exists
          for fullname.
        - If object_type is not None, the caller must ensure that a method hook exists
          for fullname.

        Return the inferred return type.
        c                    g | ]}g S r   r   r   r  s     r   r{  z;ExpressionChecker.apply_function_plugin.<locals>.<listcomp>  s    -M-M-MQb-M-M-Mr   c                    g | ]}g S r   r   rr  s     r   r{  z;ExpressionChecker.apply_function_plugin.<locals>.<listcomp>      3S3S3S1B3S3S3Sr   c                    g | ]}g S r   r   rr  s     r   r{  z;ExpressionChecker.apply_function_plugin.<locals>.<listcomp>  rt  r   c                    g | ]}g S r   r   rr  s     r   r{  z;ExpressionChecker.apply_function_plugin.<locals>.<listcomp>  s    0P0P0P0P0P0Pr   N)r  r  callee_arg_namesr  default_return_typeru  rI  api)	r   r  r  rw  r  rx  ru  rI  ry  )r  r  r  	enumerater  r  get_function_hookrs   r  r?  r  get_method_hookr   ru   )r  r  r  r  r  r}  ru  r   rH  rI  num_formalsformal_arg_typesformal_arg_exprsformal_arg_namesformal_arg_kindsformalactualsactualcallbackmethod_callbacks                       r   apply_function_pluginz'ExpressionChecker.apply_function_plugin  s=   . &*++-M-M%:L:L-M-M-M3S3Sk@R@R3S3S3S3S3Sk@R@R3S3S3S0P0PU;=O=O0P0P0P()9:: 	C 	COFG! C C (//	&0ABBB (//V=== :$V,33If4EFFFF$V,33D999 (//	&0ABBBBC {44X>>H'''8..%+%5.(.)#	 	 	   #k99(CCO"...)+66K"?$..%+%5.(.)#
 
 
  r   r   hook>Callable[[list[list[Expression]], CallableType], FunctionLike]c                H    t          |t                    rt          |j                  }t	          |||j        |j         fd          }d t          |          D             }t          |          D ]+\  }	}
|
D ]#}||	                             |                    $, |||          S t          |t                    sJ g }|j
        D ]G}                     ||||          }t          |t                    sJ |                    |           Ht          |          S )z@Helper to apply a signature hook for either a function or methodc                :                         |                    S r   rf  rv  ru  r  s    r   rw  z8ExpressionChecker.apply_signature_hook.<locals>.<lambda>      $++d1g.. r   c                    g | ]}g S r   r   rr  s     r   r{  z:ExpressionChecker.apply_signature_hook.<locals>.<listcomp>  s    7W7W7Wq7W7W7Wr   )r   r   r  r  r   r  r  rz  r  r   r   apply_signature_hook)r  r  ru  r  r  r  r}  r}  r  r  r  r  r   r  adjusteds   ` `            r   r  z&ExpressionChecker.apply_signature_hook  sa    fl++ 	%f.//K5  .....    8X7WE+DVDV7W7W7W#,-=#>#> B B% B BF$V,33DLAAAAB4(&111fj11111E ' '44T4IW[\\!(L99999X&&&&e$$$r   signature_hook,Callable[[FunctionSigContext], FunctionLike]c           	     D                           |||| fd          S )zKApply a plugin hook that may infer a more precise signature for a function.c                D     t          | |j                            S r   )rt   r  )ru  sigrI  r  r  s     r   rw  zAExpressionChecker.apply_function_signature_hook.<locals>.<lambda>2  s$    ~~.@sGUYU].^.^__ r   )r  )r  r  ru  r  rI  r  r  s   `   ` `r   apply_function_signature_hookz/ExpressionChecker.apply_function_signature_hook#  s=     ((______
 
 	
r   *Callable[[MethodSigContext], FunctionLike]c           
     f     t          |                               |||| fd          S )zIApply a plugin hook that may infer a more precise signature for a method.c           	     F     t          | |j                            S r   )rv   r  )ru  r  rI  pobject_typer  r  s     r   rw  z?ExpressionChecker.apply_method_signature_hook.<locals>.<lambda>G  s(    ..$\4gtxPP# # r   )r   r  )	r  r  ru  r  rI  r  rH  r  r  s	   `   `  `@r   apply_method_signature_hookz-ExpressionChecker.apply_method_signature_hook5  s\     '{33((      

 

 
	
r   Ncallable_namec           	     2   t          |          }|t          |t                    rp|8| j                            |          }|r|                     |||||||          S n6| j                            |          }	|	r|                     ||||||	          S |S )a6  Attempt to determine a more accurate signature for a method call.

        This is done by looking up and applying a method signature hook (if one exists for the
        given method name).

        If no matching method signature hook is found, callee is returned unmodified. The same
        happens if the arguments refer to a non-method callable (this is allowed so that the code
        calling transform_callee_type needs to perform fewer boilerplate checks).

        Note: this method is *not* called automatically as part of check_call, because in some
        cases check_call is called multiple times while checking a single call (for example when
        dealing with overloads). Instead, this method needs to be called explicitly
        (if appropriate) before the signature is passed to check_call.
        )r   r   r   r  get_method_signature_hookr  get_function_signature_hookr  )
r  r  r  ru  r  rI  r  rH  method_sig_hookfunction_sig_hooks
             r   transform_callee_typez'ExpressionChecker.transform_callee_typeM  s    0 !(($FL)I)I$&"&+"G"G"V"V" ;;i)[Ra  
 %)K$K$KM$Z$Z!$ ==i)EV   r   r  Overloaded | Nonec                h   |j         sJ t          |j                  dk    st          |          dk    rdS t          t	          |j        d                   t
                    sdS t          t	          |j                  t
                    sdS | j                                        5  | j	        
                                5  t	          |                     |d         d                    }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t          |t                    r|S dS )zSCheck if this looks like an application of a generic function to overload argument.r   Nr   r  )r  r  r  r   r   r   r?  r  r<  r  r;  rf  r   )r  r  ru  rk  s       r   "is_generic_decorator_overload_callz4ExpressionChecker.is_generic_decorator_overload_callv  s    $$$${$%%**c$ii1nn4/+*?*BCC\RR 	4/+*>??NN 	4X$$&& 	T 	T'')) T T*4;;tAwT;+R+RSST T T T T T T T T T T T T T T	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T 	T h
++ 	Ots6   (D+C9-D9C=	=D C=	DDD
overloadedr   r2  tuple[Type, Type] | Nonec                >   g }g }|j         D ]}t          |          }| j                                        5 }|                     ||gt
          g|          \  }	}
ddd           n# 1 swxY w Y   |                                rzt          |	          }t          |t                    st          |
          }t          |t                    s|
                    |           |
                    |           |r|sdS t          |          t          |          fS )a  Type-check application of a generic callable to an overload.

        We check call on each individual overload item, and then combine results into a new
        overload. This function should be only used if callee_type takes and returns a Callable.
        r_  N)r   rf   r  r;  
check_callr2   has_new_errorsr   r   r   r  r   )r  r  r  r2  r*  inferred_argsr  r  erritem_resultinferred_argp_item_resultp_inferred_args                r   handle_decorator_overload_callz0ExpressionChecker.handle_decorator_overload_call  s|    $ 	) 	)Dt$$$C'')) `S,0OOK#QXPY[^,_,_)\` ` ` ` ` ` ` ` ` ` ` ` ` ` `!!## +K88Mm\:: ,\::Nnl;;   000MM-(((( 	] 	4&!!:m#<#<<<s   #A&&A*	-A*	r  c           
        |||J |                      ||          }t          |          }|r+|                     |||j        |j        ||j        |          }n.|,t          |t                    r|                     |||          S | 	                    ||j        |j        ||j        |j
        ||          \  }}t          |          }t          |j
        t          t          f          r|j
        j        }|:|8t          |t                    r#|j                            |          x}	|	j        }| j                            ||           | j                            ||||           t          |j
        t(                    rEt          |t*                    r0|j        |j        |j
        _        |j        |j        |j
        _        |S )a?  Type check call expression.

        The callee_type should be used as the type of callee expression. In particular,
        in case of a union type this can be a particular item of the union, so that we can
        apply plugin hooks to each item.

        The 'member', 'callable_name' and 'object_type' are only used to call plugin hooks.
        If 'callable_name' is None but 'member' is not None (member call), try constructing
        'callable_name' using 'object_type' (the base type on which the method is called),
        for example 'typing.Mapping.get'.
        N)callable_noder  rH  )rj  selftype)r  r   r  ru  r  r  r   r   check_union_call_exprr  r  rV   rS   r   r   r   r  r  r)  warn_deprecated_overload_itemr]   r   
type_guardtype_is)
r  r  r$  r  rH  r  r?  proper_calleer   symbols
             r   r  z2ExpressionChecker.check_call_expr_with_callee_type  s   &  V%7*** 00fEEM%k22 	F44{AFAKAKQ\ KK J{I$F$F--afEEE $FKK('# !0 	!
 	!
+ (44ah: 677 	8=D| 2z+x7X7X 2).226:::FG!;DH%%dA...H22ak 3    ah(( 	9Z|-T-T 	9'3&3&>#$0#0#8 r   r   c                   g }|                                 D ]}| j                                        5  t          |||ddd|| j        |                                 |
  
        }ddd           n# 1 swxY w Y   |                     |j        |d          }||                     ||          }|r|nd}	|	                    | 
                    ||||	                     t          |          S )zFType check calling a member expression where the base type is a union.F)	is_lvalueis_superis_operatororiginal_typer  in_literal_context	self_typeNT)skip_non_overlapping)r  r  r;  r   r  rO  r(  r  r  r  r  r   )
r  r$  rH  r  resr_  r  r+  r  item_object_types
             r   r  z'ExpressionChecker.check_union_call_expr  sZ   --// 	 	C''))  ,#" %"-'+'>'>'@'@!                 33AHdY]3^^H 00f==M&3=ssJJ55h=Rbcc    %S)))s   1A//A3	6A3	r  Expression | Noner  tuple[Type, Type]c
                t   t          |          }t          |t                    rV|j        r3|                     ||          }
|
|                     ||
|          }||S |                     ||||||||          S t          |t                    r|                     |||||||          S t          |t                    s| j
                                        s|                     ||          S t          |t                    r|                     |||||          S t          |t                    rt!          d||ddd|	p|| j
        |                                 	  	        }|j        j        dz   }|                     |||||||          }|                     ||||||||          }|r| j
                            ||           |S t          |t.                    r|                     |j        |||||          S t          |t2                    r5|                     |j        |          }|                     ||||||          S t          |t8                    r+|                     t;          |          ||||||||	  	        S | j                            ||          t          t@          j!                  fS )a  Type check a call.

        Also infer type arguments if the callee is a generic function.

        Return (result type, inferred callee type).

        Arguments:
            callee: type of the called value
            args: actual argument expressions
            arg_kinds: contains nodes.ARG_* constant for each argument in args
                 describing whether the argument is positional, *arg, etc.
            context: current expression context, used for inference.
            arg_names: names of arguments (optional)
            callable_node: associate the inferred callable type to this node,
                if specified
            callable_name: Fully-qualified name of the function/method to call,
                or None if unavailable (examples: 'builtins.open', 'typing.Mapping.get')
            object_type: If callable_name refers to a method, the type of the object
                on which the method is being called
        Nr  FTr  r  r  r  r  r  z	.__call__r  )"r   r   r   r  r  r  r=  r   check_overload_callr   r  r9  check_any_type_callr   check_union_callr   r   rO  r   r   r  r  
store_typer   upper_boundr   analyze_type_type_calleer  r   r   r  not_callabler   r<  )r  r  ru  r  rI  r  r  r  rH  r  r  overloaded_resultcall_functionr*  r  s                  r   r  zExpressionChecker.check_call  s3   @ !((fl++ R	Y 	1!DDVTRR
) )-(K(K
G) )% )400++	 	 	 
++ <	Y++iM;PW   (( 8	Y0L0L0N0N 8	Y++D&999	** 6	Y((y)WUUU)) 4	Y1 +5vH#'#:#:#<#<
 
 
M #K0;>M 66}dIw	SY M __	 	F  ; ##M6:::M,, 	Y??"D)Wi   )) 	Y00gFFD??4y'9m\\\	** 	Y??v&&$ # 
 
 
 8((9979CW;X;XXXr   c	                    |                                                                 }||j        r|j        }t          |j                  }	|                                r!t          |	t                    r|	j        j	        }t          |t                    r|j	        t          v r	|j        |fS |                                rp|                                j        rW|j        sP j                            t"          j                            |                                j                  |           n|                                r|                                j        r|j        s|                                j        s|                                }
i }|
j        D ]/\  }}|t.          k    r                     |
|          ||<   *d||<   0 j                            |                                j        ||           |                                }|rt          |j        t:                    rd}t=          |          D ]\  }}|t>          k    rt                                |                    }t          |tB                    rtE          d |j#        D                       rH|rD j                            d|tH          j%                   tM          tN          j(                  |fc S d}tS          |||j*        |j+         fd          }t          |j                  }	t          |	tX                    r@|	j-        r9t]          |j                  }t_          |           |0                    |          }|1                                rtE          d	 |j-        D                       }te          |          } 3                    ||          }|r!tS          |||j*        |j+         fd
          } 4                    ||||||          }|r!tS          |||j*        |j+         fd          }|5                                }||t>          tl          gk    rto          |          dk    r                      d                   }                      d                   }t          |tp                    rgt          |tp                    rR|j9        tt          j;        k    r=|j9        tt          j<        k    r(|j=        |j=        cxk    r|j=        k    rn n	|j        |fS  >                    |||          } ?                    ||||||||            @                    ||||||           |                                rito          |          dk    rVt          |j         B                    d                    r.|0                    t          jD        |d                             }|r j        E                    ||           |rk| jF        G                    |          s|M jF        H                    |          r3 I                    ||||||||	  	        }|0                    |          }|j        |fS )zxType check a call that targets a callable value.

        See the docstring of check_call for more information.
        NFc              3  @   K   | ]}t          |t                    V  d S r   r   r   r   r   s     r   r   z8ExpressionChecker.check_callable_call.<locals>.<genexpr>  s=       > >23Jq*--> > > > > >r   z<Passing multiple variadic unpacks in a call is not supportedr  Tc                :                         |                    S r   r  r  s    r   rw  z7ExpressionChecker.check_callable_call.<locals>.<lambda>  s    dkk$q'** r   r?  c              3  N   K   | ] }t          |t          t          f          V  !d S r   )r   r   r   r   vs     r   r   z8ExpressionChecker.check_callable_call.<locals>.<genexpr>  sC        EF
1}.>?@@     r   c                :                         |                    S r   r  r  s    r   rw  z7ExpressionChecker.check_callable_call.<locals>.<lambda>      dkk$q'22 r   c                :                         |                    S r   r  r  s    r   rw  z7ExpressionChecker.check_callable_call.<locals>.<lambda>  r  r   r  r   r   rH  r  )Jwith_unpacked_kwargswith_normalized_var_argsr;  r   r?  r  r   r   r   r   r]   rx   r  r  from_type_typer  r  r   CANNOT_INSTANTIATE_PROTOCOLr  is_abstractfallback_to_anyabstract_attributesr5   can_return_noner  !cannot_instantiate_abstract_classvar_argr_  r   r  r3   rf  r   r  r   r  CALL_ARGr   r   r<  r   r  r  r   r  r%   r   copy_modified
is_genericr&   +infer_function_type_arguments_using_contextr(   
param_specr4   r  r   flavorr   ARGSKWARGSidinfer_arg_types_in_contextcheck_argument_countcheck_argument_typesr{   r8  r   make_normalizedr  r  r{  r|  r  )r  r  ru  r  rI  r  r  r  rH  r?  r   r  	attr_nameabstract_statusr  seen_unpackr  arg_kindrk  r}  fresh_ret_typeneed_refreshr  arg1arg2r  new_ret_types   ` `                        r   r=  z%ExpressionChecker.check_callable_callt  s5     ,,..GGII V[ "KM"6?33 	3Jx$B$B 	3$M2MmW-- 	+-2HJ2V2V?F**   	""$$0	 )		 HMM <CCFDVDVDXDXD]^^   
   	""$$0	 )		
 &&((8	 %%''D 46.2.F ; ;*	?"&999595I5I$PY5Z5Z'	225:'	22H66""$$)+>   .."" 	'z'+z:: 	'  K!$T9!5!5 ' 'Xx''*4;;s+;+;<<!(I66 
'# > >7?~> > > ; ; 
' # EZ#!& &   
  'y';<<fDDDD"&K1*****
 
 #6?33h-- 	C(2D 	C<V_MMN 000))>)BBF 	  JPJZ    L 077FEEfgVVF 
 $:$$22222$ $  77i4DlT[ F  #9$$22222$ $  &&((
"h	222$%%**;;tAw''D;;tAw''D4///t]33/ K?#777K?#999Gtw7777*-77777..33FD)M]^^	!!		
 		
 		
 	!!y$0@'Wb 	" 	
 	
 	

   	[Y1$$fot/O/OPP % ))83KIVWL3Y3Y)ZZF 	7Hv666 	A T[%B%B=%Q%Q 'DK,G,G,V,V'55 
 
L ))<)@@F&&r   r   r  c                   t           j        sdS |j        D ]}|j                            |          }||j        }t          |t                    r|j        }t          |t                    r|j
        }t          |t                    rK|j        Dt          |j        t                    sJ t          t                      |j        j                  c S dS )zIs the given attribute a method with a None-compatible return type?

        Overloads are only checked if there is an implementation.
        F)ry   strict_optionalmrorW  r  r   r   rY   implrE   funcrL   r   r   r}   r   r?  )r  r   r  rh  symnoder   s         r   r  z!ExpressionChecker.can_return_none/  s    
 $ 	 5H 	F 	FDjnnY//G<D$ 122 !y$	** !y$(( F9(%di>>>>>%hjj$)2DEEEEEur   r  c                    t          t                    rt          t          j                  S t          t                    rt          j         j                  }t          |t                    r|	                    d          }t          |          }t          |t                    r|	                    g           }|S t          t                    r4t           fd                                D             j                  S t          t                    r                     t!          j                            }t!          |          }t          |t                    r|	                              }n5t          |t$                    r t%          fd|j        D                       }|S t          t(                    r@t+                    j        j        dk    r#                     t+                              S t          t.                    r                               S  j                                       t          t          j                  S )	zzAnalyze the callee X in X(...) where X is Type[item].

        Return a Y that we can pass to check_call(Y, ...).
        
source_anyT)r  r  c                V    g | ]%}                     t          |                    &S r   )r  r   )r   r  rI  r  s     r   r{  z>ExpressionChecker.analyze_type_type_callee.<locals>.<listcomp>Z  sA        11/"2E2EwOO  r   r  c                <    g | ]}|                                S )r  r  )r   cr  s     r   r{  z>ExpressionChecker.analyze_type_type_callee.<locals>.<listcomp>j  s'    $Z$Z$ZQ__d_%C%C$Z$Z$Zr   builtins.tuple)r   r   r   from_another_anyr   r   r   r8  r   r  r$   r   r  r@  r   r  r   r  r   r   r   r   r   r   r&  r  unsupported_type_typer<  )r  r  rI  r  expandedr  s   ```   r   r  z*ExpressionChecker.analyze_type_type_calleeG  sb   
 dG$$ 	H95$GGGGdH%% 		"49do>>C#|,, =''t'<<.sD99H(L11 @ $11B1??OdI&& 	    "1133   	   dK(( 	
 22?4CS3T3TV]^^F$V,,F&,// \--t-<<FJ// \#$Z$Z$Z$ZV\$Z$Z$Z[[MdI&& 	P>$+?+?+D+MQa+a+a001E1EwOOOdM** 	>77===&&tW555y+,,,r   c                    g }|D ]]}|                      |          }t          |          r"|                    t                                 H|                    |           ^|S )zInfer argument expression types in an empty context.

        In short, we basically recurse on each argument without considering
        in what context the argument was called.
        )rf  has_erased_componentr  r   )r  ru  r  r  rk  s        r    infer_arg_types_in_empty_contextz2ExpressionChecker.infer_arg_types_in_empty_contextu  sl      	% 	%C{{3''H#H-- %

8::&&&&

8$$$$
r   c                T    t           j        }t          |          rdt           _        |S )ax  Adjust type inference of unions if type context has a recursive type.

        Return the old state. The caller must assign it to type_state.infer_unions
        afterwards.

        This is a hack to better support inference for recursive types.

        Note: This is performance-sensitive and must not be a context manager
        until mypyc supports them better.
        T)r   infer_unionsr   )r  r  olds      r   $infer_more_unions_for_recursive_typez6ExpressionChecker.infer_more_unions_for_recursive_type  s)     %|,, 	+&*J#
r   c                
   dgt          |          z  }t          |          D ]q\  }}|D ]i}||                                         sM|j        |         }	|                     |	          }
|                     ||         |	          ||<   |
t          _        jrt          |          D ]%\  }}|s|                     ||                   ||<   &t          d |D                       sJ t          t          t                   |          S )a  Infer argument expression types using a callable type as context.

        For example, if callee argument 2 has type List[int], infer the
        argument expression with List[int] type context.

        Returns the inferred types of *actual arguments*.
        Nc              3     K   | ]}|d uV  	d S r   r   )r   r  s     r   r   z?ExpressionChecker.infer_arg_types_in_context.<locals>.<genexpr>  s&      00b2T>000000r   )r  rz  is_starr  r  rf  r   r  r   r   r  r   )r  r  ru  r  r}  r  rv  r  airk  r  r   s               r   r  z,ExpressionChecker.infer_arg_types_in_context  s    #'#d))!3#$455 	2 	2JAw 2 2 },,.. 
2%/2H CCHMMC"kk$r(H==CG.1J+2 cNN 	. 	.DAq .T!W--A00C00000000DJ$$$r   callableerror_contextc                r   | j         d         }|s|S t          |t                                }|j        }t	          |          r-t	          |          rt          |          }t          |          }t          |t                    r2t          |          s#t          |          s|
                                S t          |j        ||d          }g }|D ]K}t          |          st          |          r|                    d           6|                    |           L|                     |||d          S )a  Unify callable return type to type context to infer type vars.

        For example, if the return type is set[t] where 't' is a type variable
        of callable, and if the context is set[int], return callable modified
        by substituting 't' with 'int'.
        r0  Tskip_unsatisfiedN)r  r    r   r?  r   r   r   r   r   r   r  r)   r  has_uninhabited_componentr  r  apply_generic_arguments)	r  r  r  r2  
erased_ctxr?  ru  new_argsr  s	            r   r  z=ExpressionChecker.infer_function_type_arguments_using_context  sg    # 	O 'sJLL99
$x(( 	5-@-E-E 	5 'x00H(44J h,, 	00 's++ 04H4M4M 0--///#*t
 
 
 ') 	% 	%C(-- %1Ec1J1J %%%%%$$$$ ++h , 
 
 	
r   r  c           
          j                                         r j                                        5                       ||          }ddd           n# 1 swxY w Y                        ||t                              }	g }
t          |          D ]<\  }}|	|         dk    r|
                    d           '|
                    |           =t          |
||| 
                                 j                                                   \  }}d|	v r                     ||||||          \  }j        dk    rt          |          dk    rt          |v s	t          |v rt          |d                   }t!          |t"          t$          f          r                     d          |d<   nJ|r#t)                               d          |          s% j                             t,          j        |            j         j        j        st5          fd|D                       r|r!t7          ||j        j         fd	          }t          |||| 
                                 j                                         d
          \  }                     ||          }t?          j         |          }|*tC          d |D                       rtE          |           |S t%                      d
_#        fd|D             }n/tI          tJ          j&                  gt          j'                  z  } (                    ||          S )zInfer the type arguments for a generic callee type.

        Infer based on the types of arguments.

        Return a derived callable type that has the arguments applied.
        Nr   )rI  strictr  dictr   builtins.strc              3     K   | ][}|d u pRt          t          |          t                    p0t          t	          |                    t          j                  z  V  \d S r   )r   r   r   r   r   r  )r   r  r  s     r   r   zBExpressionChecker.infer_function_type_arguments.<locals>.<genexpr>W  s       ? ?  T	 Foa00/BBF}Q''((3{/D+E+EE? ? ? ? ? ?r   c                :                         |                    S r   r  r  ru  r  s    r   rw  zAExpressionChecker.infer_function_type_arguments.<locals>.<lambda>f  s    $++d1g"6"6 r   T)rI  r(  allow_polymorphicc              3  d   K   | ]+}|d uo"t          t          |          t                     V  ,d S r   )r   r   r   r  s     r   r   zBExpressionChecker.infer_function_type_arguments.<locals>.<genexpr>|  sT       / / TMY*_Q5G5G*Y*Y&Y/ / / / / /r   c           	     z    g | ]7}|1t          |fdt          j                  z   D                       nd 8S )Nc                     i | ]
}|j         S r   )r  )r   r  unknowns     r   
<dictcomp>zNExpressionChecker.infer_function_type_arguments.<locals>.<listcomp>.<dictcomp>  s    ___!g___r   )r#   r  r  )r   r  r  	free_varsr2  s     r   r{  zCExpressionChecker.infer_function_type_arguments.<locals>.<listcomp>  sq     	! 	! 	!  = $____tK<Q7R7RU^7^___   "	! 	! 	!r   ))r  r9  r  r;  r  get_arg_infer_passesr  rz  r  r(   argument_infer_context#infer_function_type_arguments_pass2special_sigr1   r4   r   r   r   r   r8  r}   r  r   &KEYWORD_ARGUMENT_REQUIRES_STR_KEY_TYPEr  r  r  r   r  r  r$  r   
apply_polyr   r   r  r   r   unannotatedr  apply_inferred_arguments)r  r  ru  r  r  r}  r  rI  r  arg_pass_nums
pass1_argsrv  r  r  r  	first_argpoly_inferred_argspoly_callee_typeappliedr4  r2  s   ```                @@r   r(   z/ExpressionChecker.infer_function_type_arguments
  sP     8'')) x	Z
 ''))   ;;y2B 	              
 !55T9.>D		 M -/J#I.. + +3 #a''%%d++++%%c****< 3355x3355     M1 M!!/3/W/W$! 	0 	0,m '611&&!++)++yI/E/E ,M!,<==	i(O)DEE d'+~'F'FM!$$" d*T__^5T5TV_*`*` dHMM"2"Y[bccc8#6 73 ? ? ? ? '	? ? ? < < 7   
 (>!!#-#-66666( ($ 1N$ 779987799&*	1 	1 	1-"I $(#?#?!3W$ $ 
 $./?KK&3 / /// / / , ,& )111"N)++$(!	! 	! 	! 	! 	! 	! 0	! 	! 	! %Y%:;;<s;CX?Y?YYM,,[-QQQs   AA"%A"old_inferred_argsSequence[Type | None]&tuple[CallableType, list[Type | None]]c	           	     *    t          |          }	t          t          |	                    D ]5\  }
}t          |t          t
          f          st          |          rd|	|
<   6                     ||	|          }|r!t          |||j	        |j
         fd          } j                                        5                       |||          }ddd           n# 1 swxY w Y   t          |||||                                           \  }	}||	fS )a^  Perform second pass of generic function type argument inference.

        The second pass is needed for arguments with types such as Callable[[T], S],
        where both T and S are type variables, when the actual argument is a
        lambda with inferred types.  The idea is to infer the type variable T
        in the first pass (based on the types of other arguments).  This lets
        us infer the argument and return type of the lambda expression and
        thus also the type variable S in this second pass.

        Return (the callee with type vars applied, inferred actual arg types).
        Nc                :                         |                    S r   r  r-  s    r   rw  zGExpressionChecker.infer_function_type_arguments_pass2.<locals>.<lambda>  r  r   r(  )r  rz  r   r   r   r   r  r$  r   r  r  r  r;  r  r(   r6  )r  r  ru  r  r  r}  rC  r  rI  r  rv  r  r  r  s   ` `           r   r7  z5ExpressionChecker.infer_function_type_arguments_pass2  s   2 .// 0 ? ?@@ 	( 	(FAs#/:;; (?STW?X?X (#'a 22;wWW 	5%%.....    X##%% 	 	77T9.> I	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 9//11
 
 
q M))s   7CC #C r'   c                    t          | j                            d          | j                            d                    S )Nr  typing.Iterable)r'   r  r8  r"  s    r   r6  z(ExpressionChecker.argument_infer_context  s;    #H 011483F3FGX3Y3Y
 
 	
r   num_actualsint	list[int]c                b   dg|z  }t          |j                  D ]\  }}d}	t          |j        |                   }
t          |
t                    r|
                                r||         D ]}t          ||                   }t          |t                    r$t          d||d          }|t          |          }t          |t                    r&|j        st          ||         t                    sd}	 n|	s1|
                    t                                r||         D ]}d||<   |S )a  Return pass numbers for args for two-pass argument type inference.

        For each actual, the pass number is either 1 (first pass) or 2 (second
        pass).

        Two-pass argument type inference primarily lets us infer types of
        lambdas more effectively.
        r   Fr  T)r  Nr  )rz  r  r   r   r   r  r   rz   r  rP   rf  ArgInferSecondPassQuery)r  r  ru  r  r}  rJ  r  rv  r  skip_param_specp_formalrz  p_actualcall_methods                 r   r5  z&ExpressionChecker.get_arg_infer_passes  sZ     cK 011 	 	FAs#O&v'7':;;H(L11 h6I6I6K6K )!,  A.y|<<H "(H55 D&1*h^b&c&c&c&2'6{'C'CH"8\:: ( 2 !+47J ? ?
 +/" szz2I2K2K'L'L )!,  ACFF
r   r  c                   t          |          D ]_\  }}|rt          |          rI| j                            ||dz   |           t	          t
          j                  gt          |          z  }`|                     |||          S )zApply inferred values of type arguments to a generic function.

        Inferred_args contains the values of function type arguments.
        r   )	rz  r  r  could_not_infer_type_argumentsr   r   r<  r  r$  )r  r  r  rI  rv  inferred_types         r   r<  z*ExpressionChecker.apply_inferred_arguments	  s     !*- 8 8 	U 	UA}  U$8$G$G U77QUGTTT!()=!>!> ?#mBTBT T ++KPPPr   actual_typesactual_kindsactual_namesContext | Nonec	                   |&t          t          t          j                            }i }	|D ]#}
|
D ]}|	                    |d          dz   |	|<   $|                     ||||	|          \  }}t          |j                  D ]x\  }}||         }|                                r|s|s~|	                                r<| j
                            |||           |r|rd|v r|                     |||           n+|j        |         pd}| j
                            |||           d}|                                sxt!          ||          rg| j                                        s.t'          t)          |d                            t*                    r| j
                            |||           d}0|                                rG|rE||d                  t0          j        t0          j        fvr| j
                            ||           d}|                                |s+|j        dk    r | j
                            |||           d}t=          |          dk    rt?          fd|D                       }||d                  t0          j         k    r#|dk    r| j
        !                    d	|           d}||d                  t0          j        k    r#|dk    r| j
        !                    d
|           d}z|S )aO  Check that there is a value for all required arguments to a function.

        Also check that there are no duplicate values for arguments. Report found errors
        using 'messages' if it's not None. If 'messages' is given, 'context' must also be given.

        Return False if there were any errors. Otherwise return True
        Nr   r   r   ?Fpartialc              3  h   K   | ],}t          t          |                   t                    V  -d S r   )r   r   r   )r   krV  s     r   r   z9ExpressionChecker.check_argument_count.<locals>.<genexpr>Y	  sM       , , #?<?#C#C]SS, , , , , ,r   z)ParamSpec.args should only be passed oncez+ParamSpec.kwargs should only be passed once)"rf   r   r   r5  r   check_for_extra_actual_argumentsrz  r  is_requiredis_positionalr  too_few_argumentsmissing_classvar_callable_noter  missing_named_argumentr  is_duplicate_mappingr  r9  r   r   r   duplicate_argument_valueis_namedr   r1   r4   too_many_positional_argumentsr  r8  r  sumr3   r  )r  r  rV  rW  rX  r}  rI  rH  r  all_actualsr  r  okis_unexpected_arg_errorrv  kindmapped_argsargnameparamspec_entriess     `                r   r  z&ExpressionChecker.check_argument_count	  sq   $ ?wy'=>>??G
 ')' 	; 	;G ; ;!,A!6!6!:A; '+&K&KL,k7'
 '
##
 !!122 *	# *	#GAt*1-K!! (#+ (#>U (#%%'' NH..vwMMM" a} a9M9M;;KX_```$.q18SGH33FGWMMM\\^^ #(<\<) ) # 8//11 Z#LQ$@AA96 6  H55faIIIB## !Q0%/8ZZZ 66vwGGG""$$0" #v'9Y'F'FH..vwMMMBB%%))(+ , , , ,!,, , , ) )% $KN3u~EEJ[^_J_J_&QSZ[[["#KN3uFFK\_`K`K`&SU\]]]"	r   rj  tuple[bool, bool]c                p   d}d}t          |          D ]\  }	}
|	|vr|
t          j        k    st          ||	                   r~|
t          j        k    rnd}|
t          j        k    r| j                            ||           m|s
J d            ||	         }|J ||	         }| j                            ||||           d}|
t          j        k    rt          j        |j	        vs|
t          j        k    rt          ||	                   }t          |t          t          f          r|                    |	d          t          |j                  k     ra|
t          j        k    st          |t                    s| j                            ||           n| j                            |||           d}d}||fS )zCheck for extra actual arguments.

        Return tuple (was everything ok,
                      was there an extra keyword argument error [used to avoid duplicate errors]).
        FTz/Internal error: named kinds without names givenNr   )rz  r   r3   is_non_empty_tupler4   r1   r  too_many_argumentsunexpected_keyword_argumentr  r   r   r   r   r  r  r   "too_many_arguments_from_typed_dict)r  r  rV  rW  rX  rj  rI  rl  rk  rv  rm  act_nameact_typeactual_types                 r   r_  z2ExpressionChecker.check_for_extra_actual_argumentse	  s    #( .. %	# %	#GAt$$ ''+=l1o+N+N' '' 5?**H//@@@@'ZZ)ZZZZ+AH#///+AHH888U\]]].2++&&5>AQ+Q+Q((-l1o>>kI}+EFF 
#"q!,,s;3D/E/EEE5?22*[R_:`:`2 H77HHHH HGG &W   7;3" ***r   c                   t          |t                    rt          |t                    r|                    dd          \  }}|j                            |          }|Wt          |j        t                    r?|j        j        s5|j        j	        s+| j
                            d| d|           d S d S d S d S d S d S d S )Nr   r   )maxsplitr1  zN" is considered instance variable, to make it class variable use ClassVar[...])r   r   r   r   r   r  r   ro   r  is_classvarr  note)r  rH  r  rI  r  var_namer   s          r   rc  z0ExpressionChecker.missing_classvar_callable_note	  s     k:.. 		:k83T3T 		'..sQ.??KAx#''11DJty#$>$>y, TY5J HMMGH G G G    		 		 		 		     r   	check_argArgChecker | Nonec	                    |p| j         }t          |                                           }	t                    D ]\  }
}t	          |
          }
|t
          j        k    r0|                     |
          s| j        	                    |
|           |t
          j
        k    rY|                     |
          sDt          |
| j                            d                    }| j                            |
||           t!          |          D ]S\  }}t	          |j        |                   }d}fd|D             }t%          |          dk    rCt	          |d                            }t'          |t(                    rt%          |j                  dk    rt'          |j        d         t,                    r|t
          j        gt
          j        gt%          |          dz
  z  z   k    r|j        d         gfd|dd         D             z   }t'          |t,                    rnt	          |j                  }t'          |t(                    rE|j        sJ |j        }t
          j        gt
          j        gt%          |j                  dz
  z  z   }d}|sUfd	|D             }t'          |t,                    r t	          |j                  }t'          |t(                    rUt3          |j                    !|j        }t.          gt%          |          z  }n|j                  }t'          |t,                    sJ t	          |j                  }t'          |t4                    r6|j        } fd
t7          t%          |j                            D             }nMt'          |t8                    sJ |j        j        dk    sJ |j        d          |j        d         gt%          |          t%          |j                  z
  dz   z  z   |j         dz   d         z   }t.          gt%          |          z  }nt'          |t4                    r|g}t          g}nt'          |t8                    sJ |j        j        dk    sJ |j        d         gt%          |          z  }t.          gt%          |          z  }n1|gt%          |          z  }|j        |         gt%          |          z  }t%          |          t%          |          cxk    rt%          |          k    sn J t%          |          t%          |          k    rdt%          |          t%          |          k    r!| j        j                             ||           n!| j        j        !                    ||d           t%          |          t%          |          k    sJ t%          |          t%          |          k    sJ t          |||||          D ]`\  }}}}}|	"                    |||j#        |         |t'          |t,                              } ||||||dz   |dz   ||||         |
  
         aUdS )zCheck argument types against a callable type.

        Report errors if the argument types are not compatible.

        The check_call docstring describes some of the arguments.
         _typeshed.SupportsKeysAndGetItemFc                     g | ]
}|         S r   r   )r   r  r  s     r   r{  z:ExpressionChecker.check_argument_types.<locals>.<listcomp>	  s    :::QIaL:::r   r   r   c                     g | ]
}|         S r   r   r   r  r  s     r   r{  z:ExpressionChecker.check_argument_types.<locals>.<listcomp>	  s    >a>a>aPQy|>a>a>ar   NTc                     g | ]
}|         S r   r   r  s     r   r{  z:ExpressionChecker.check_argument_types.<locals>.<listcomp>	  s    >>>	!>>>r   c                8    g | ]}|k    rt           nt          S r   )r2   r3   )r   rv  inner_unpack_indexs     r   r{  z:ExpressionChecker.check_argument_types.<locals>.<listcomp>	  s8     4" 4" 4"() 014F/F/FGGH4" 4" 4"r   r  )allow_unpack)$r  r   r6  r  r   r   r3   is_valid_var_argr  invalid_var_argr4   is_valid_keyword_var_argr}   r  r8  invalid_keyword_var_argrz  r  r  r   r   r   r   r2   r   r   r   r  r   r   ru  r  rt  rb  expand_actual_typer  )!r  r  r  ru  r  r}  rI  r  rH  mapperrk  r  
is_mappingrv  r  orig_callee_arg_typeexpanded_tuplerW  p_actual_typerV  p_callee_typecallee_arg_typescallee_arg_kindsunpacked_typeinner_unpackinner_unpacked_typer  ry  actual_kindcallee_arg_typecallee_arg_kindexpanded_actualr  s!    ``                             @r   r  z&ExpressionChecker.check_argument_types	  s   " /	 !<!<!>!>??"%i";"; 	P 	PHh&x00H5>))$2G2G2Q2Q)((7;;;5?**43P3PQY3Z3Z*'dh112TUU 
 00:wOOO#$455 l	 l	JAw#263CA3F#G#G  #N::::':::L7||a /	'!*0E F F}i882M/00A55"=#6q#9:FF 6$(8EM?cRYll]^N^;_(___$1$7$:#;>a>a>a>aU\]^]_]_U`>a>a>a#aL!"6
CC 2(78L8Q(R(R%mY?? 2#0#6666/</B,05/?5=/ #M$7 8 81 <C 0, .2N! *L>>>>g>>>2J?? (L$34H4M$N$NM!-;; #D-@AT-U-U*-5/</B,07y3w<</G,,+8+>?Q+RL#-lJ#G#GGGG2A,BS2T2T/)*=?OPP L 4A3F 04" 4" 4" 4"-23}7J3K3K-L-L4" 4" 4" 0 0 (22Ex'P'P P P P':'?'HL\'\'\'\'\$1$78K9K8K$L':'?'B&C'*7||c-:M6N6N'NQR'R'T%T '4&9:Lq:P:R:R&S%T !1 5<9s7||3K 0 0#M3CDD D,@+A(,4:(()-BBBBB,1:>NNNNN,9,>q,A+BS\\+Q(,39s7||+C(((<'=G'L$(.(8(;'<s7||'K$|$$GIIIIL8I8IIIIIII#$$L(9(999|$$s+;'<'<<<HL33FGDDDDHL2267DIII'((C,=,====='((C0@,A,AAAAAVY|5EGWW W  R[/? #)";";$Q'#!+OZ!H!H #< # # 	##QJEL   ml	 l	r   caller_typeoriginal_caller_typecaller_kindr:   r^  mouter_contextc           
     V   t          |          }t          |          }t          |          }t          |t                    r| j                            ||	           dS |                     ||          r| j                            ||	           dS t          ||| j        j	                  sx| j        
                    |||||||	|
          }| j                            |||	|           | j                                        s!| j                            |||	|           dS dS dS )z.Check the type of a single argument in a call.)r  )rH  rI  r  r  N)r   r   r   r  deleted_as_rvaluehas_abstract_type_partconcrete_only_callr}   r  r  incompatible_argumentincompatible_argument_noteprefer_simple_messagescheck_possible_missing_await)r  r  r  r  r  r^  r  r  rH  rI  r  r  s               r   r  zExpressionChecker.check_arg=
  se    &k22./CDD%k22k;// 	_H&&{G<<<<<((kBB 	_H''W=====Kdh>NOOO 	_811$'+ 2 	 	D H//$k7 0    82244 _55k;PWY]^^^^^	_ 	__ _r   c                    |                                 }                     |          }                     ||||          }	d}
d}                     ||	          }d}t	           fd|D                       r	  j                                        5                       |	||||||||	  	        }ddd           n# 1 swxY w Y   |rVt          | \  }}t          t          |          |j        |j                                       t          |                    f}n# t          $ r d}Y nw xY w                     |	|||||||          }|L|Jt#          |d         |d                   r,t%          t'          |d                   t(                    s|s|S |S ||S ||S                      |	|||||          }
t-          |
          dk    r	|
d         }nUt)          t.          j                  }t3          |          sd}nt4          j        } j                            ||||                                |||||||          }|r'|s% j                            t@          j!        |           |S )z(Checks a call to an overloaded function.NFc              3  B   K   | ]}                     |          V  d S r   )
real_union)r   r  r  s     r   r   z8ExpressionChecker.check_overload_call.<locals>.<genexpr>
  s/      99ts##999999r   Tr   r  r  rH  )"r  r  plausible_overload_call_targetspossible_none_type_var_overlapr  r  r;  union_overload_resultr  r   r  r@  rA  combine_function_signaturesr   r   infer_overload_return_typer}   r   r   r   overload_erased_call_targetsr  r   r<  is_operator_methodr  OPERATORno_variant_matches_argumentsr  r  r  r   TOO_MANY_UNION_COMBINATIONS)r  r  ru  r  r  r  rH  rI  r  plausible_targetserased_targetsunioned_resultnone_type_var_overlapunion_interruptedunioned_returnreturnsinferred_typesinferred_resultrj  r  r*  s   `                    r   r  z%ExpressionChecker.check_overload_calle
  sU    ,,..99$??	 @@y)V
 
 5937
 !% C CIO` a a!9999y99999 	X++--  %)%?%?)!!!%#-
& 
&N              " " 	.1>.B+G^ .d7mmW\7>ZZ889I.9Y9YZZ&N ! ) ) )$(!!!)" 99	
 	
 &>+E ?1-~a/@AA'"??13E#F#FPP' .'
 '&!!'!!("" ::y)Yg
 
 ~"" *!,FF Y122F%m44 &~H11&)WSW1XXX'# ! 
 
  	Q%: 	QHMM*FPPPs6   ;D" B>2D" >CD" CD" "D10D1r   list[CallableType]c           
        d
d}g }g }d}d}	t          |          D ]5\  }
}|
t          k    r ||          sd}|
t          k    r ||          sd}	6|j        D ]}t	          |||j        |j        fd          }| j                                        5  |	                                |
                    |           nm|                     ||||d	          rS|r|j        r|
                    |           n4|	r|j        r|
                    |           n|
                    |           d	d	d	           n# 1 swxY w Y   ||z   S )aE  Returns all overload call targets that having matching argument counts.

        If the given args contains a star-arg (*arg or **kwarg argument, except for
        ParamSpec), this method will ensure all star-arg overloads appear at the start
        of the list, instead of their usual location.

        The only exception is if the starred argument is something like a Tuple or a
        NamedTuple, which has a definitive "shape". If so, we don't move the corresponding
        alternative to the front since we can infer a more precise match using the original
        order.r_  r   r   r   c                    t          |           } t          | t          t          f          p t          | t                    o| j        j        S r   )r   r   r   r   r   r   is_named_tupler  s    r   	has_shapezDExpressionChecker.plausible_overload_call_targets.<locals>.has_shape
  sB    !#&&CcI}#=>> 3))Ech.Er   FTc                    |          S r   r   rv  r  s    r   rw  zCExpressionChecker.plausible_overload_call_targets.<locals>.<lambda>  s    iXYl r   Nr_  r   r   r   )r  r3   r4   r   r   r  r  r  r;  r  r  r  
is_var_arg	is_kw_arg)r  r  r  r  r   r  matchesstar_matchesargs_have_var_argargs_have_kw_argrm  r_  r}  s    `           r   r  z1ExpressionChecker.plausible_overload_call_targets
  s   $	 	 	 	 ')+-! Y	22 	( 	(ID#x		#$(!y  3 #' > 	, 	,C59cmS]DZDZDZDZ    '')) , ,>>##/ NN3''''..Iy:JD  , ) ,S^ ,$++C0000) ,cm ,$++C0000s+++!, , , , , , , , , , , , , , ,$ g%%s   BD::D>	D>	r  c	                V   g }	g }
g }t          t          t          |                    }g }|D ]`}| j        | j        j        u sJ | j                                        5 }| j                                        5 }|                     |||||||          \  }}ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                                 }|r|s | j        	                    |           ||fc S t          |          }t          |t                    r|	                    |           n|	                    |           |
                    |           |                    |           |                    |           b|	sdS t          |	|
|||          rt          |
          r0| j        	                    |d                    |
d         |d         fS t          d |
D                       rJ| j        	                    |d                    t!          |
d                   t!          |d                   fS |                     t#          t$          j                  ||||||          S | j        	                    |d                    |
d         |d         fS )a  Attempts to find the first matching callable from the given list.

        If a match is found, returns a tuple containing the result type and the inferred
        callee type. (This tuple is meant to be eventually returned by check_call.)
        If multiple targets match due to ambiguous Any parameters, returns (AnyType, AnyType).
        If no targets match, returns None.

        Assumes all of the given targets have argument counts compatible with the caller.
        )r  ru  r  r  rI  r  rH  Nr   c                ,    g | ]}t          |          S r   )r   )r   r_  s     r   r{  z@ExpressionChecker.infer_overload_return_type.<locals>.<listcomp>h  s     I I ISC I I Ir   )r  maphas_any_typer  r  r;  r<  r  r  store_typesr   r   r   r  any_causes_overload_ambiguityall_same_typesr   r   r   r5  )r  r  ru  r  r  r  r  rH  rI  r  return_typesr  args_contain_any	type_mapsr_  wr  r?  
infer_typeis_matchp_infer_types                        r   r  z,ExpressionChecker.infer_overload_return_type&  sV   * ')#%%'s<;;<<24	$ 	$ 	$C8tx|++++'')) 
QX,,.. 	!+/??"!"+"+ '&3$/ ,; , ,(Hj	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ++---H $ ( 0H((+++#Z////.z::lL99 ( NN<0000NN3'''##H---%%j111  ### 	64*7L)YXabb 	6 l++ $$Yq\222#Aq(999 I IL I I IJJ $$Yq\222!,q/22J~a?P4Q4QQQ"9#9::''#"/ + '    H  1...?N1$555s6   B;8 B$B;$B((B;+B(,B;;B?	B?	c           	     r    g }|D ]1}|                      ||||||          r|                    |           2|S )zReturns a list of all targets that match the caller after erasing types.

        Assumes all of the given targets have argument counts compatible with the caller.
        )erased_signature_similarityr  )	r  r  r  r  r  ru  rI  r  r_  s	            r   r  z.ExpressionChecker.overload_erased_call_targetsz  sW     ')$ 	$ 	$C//9isG  $ s###r   c                   |r|sdS d}t          |          D ]H}t          |t                    st          |j                  D ]}t          |t                    rd} nI|sdS t          d |D                       }t          |          D ];t          fd|D                       rt          fd|D                       r dS <dS )a  Heuristic to determine whether we need to try forcing union math.

        This is needed to avoid greedy type variable match in situations like this:
            @overload
            def foo(x: None) -> None: ...
            @overload
            def foo(x: T) -> list[T]: ...

            x: int | None
            foo(x)
        we want this call to infer list[int] | None, not list[int | None].
        FTc              3  >   K   | ]}t          |j                  V  d S r   )r  r  r   r  s     r   r   zCExpressionChecker.possible_none_type_var_overlap.<locals>.<genexpr>  s,      EEaQ[))EEEEEEr   c              3  r   K   | ]1}t          t          |j                           t                    V  2d S r   )r   r   r  r   r   r  rv  s     r   r   zCExpressionChecker.possible_none_type_var_overlap.<locals>.<genexpr>  sL        JK
?1;q>::HEE     r   c              3  r   K   | ]1}t          t          |j                           t                    V  2d S r   )r   r   r  r   r  s     r   r   zCExpressionChecker.possible_none_type_var_overlap.<locals>.<genexpr>  sL        MN
?1;q>::KHH     r   )r   r   r   r   r   minr  r  )r  r  r  has_optional_argrk  r  
min_prefixrv  s          @r   r  z0ExpressionChecker.possible_none_type_var_overlap  sI    ! 		 	5 (33 	 	Hh	22 (88  dH-- '+$E   	5EE3DEEEEE
z"" 	 	A    O`         Rc    
 ttur   r   r  levellist[tuple[Type, Type]] | Nonec                   |
t           k    rt          t          |          D ]\  }}|                     |          r nR|                     ||          5  |                     ||||||||	          }ddd           n# 1 swxY w Y   ||gS dS |s~|                     ||          5  |                     ||||||||	          }ddd           n# 1 swxY w Y   |2t          t          |d                   t          t          f          s|gS t          ||                   }t          |t                    sJ g }|
                                D ]V}|                                }|||<   |                     |||||||||	|
dz   
  
        }||                    |           T dS t                      }g }|D ]0}||vr*|                    |           |                    |           1|S )a  Accepts a list of overload signatures and attempts to match calls by destructuring
        the first union.

        Return a list of (<return type>, <inferred variant type>) if call succeeds for every
        item of the desctructured union. Returns None if there is no match.
        Nr   r   )r   r   rz  r  type_overrides_setr  r   r   r   r   r  copyr  rQ  r   r   r  )r  r  ru  r  r  r  r  rH  r  rI  r  idxr_  r  directfirst_union	res_itemsr  new_arg_types
sub_resultseenr*  pairs                          r   r  z'ExpressionChecker.union_overload_result  s   , J "),, 	 	HCs##  ((y99 
 
55%!	 	
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 u4 % 	 ((y99 
 
88%!	 	
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 !*q	**Y,@+ +! x &in55+y11111	..00 	 	D%NN,,M!%M#33!%	 J %  ,,,, tt (+uu 	$ 	$D4d###s$   A>>BB(CCCc                    t          |          }t          |t                    o$t          |                                          dk    S r  )r   r   r   r  r  r  r_  s     r   r  zExpressionChecker.real_union  s=    c""#y))Kc#2D2D2F2F.G.G!.KKr   exprsSequence[Expression]	overridesSequence[Type]Iterator[None]c              #     K   t          |          t          |          k    sJ t          ||          D ]\  }}|| j        |<   	 dV  |D ]
}| j        |= dS # |D ]
}| j        |= w xY w)z5Set _temporary_ type overrides for given expressions.N)r  r  r  )r  r  r  r   r_  s        r   r  z$ExpressionChecker.type_overrides_set  s      
 5zzS^^++++UI.. 	, 	,ID#(+D%%	.EEE . .'--. . . .'--.s   A A(r   list[ProperType]AnyType | CallableTypec                   |s
J d            t          d |D                       st          t          j                  S t	          d|          }t          |          dk    r|d         S t          |          \  }}d t          t          |d         j                            D             }t          |d         j
                  }g }d}|D ]}t          |          t          |j
                  k    rd} nt          t          ||j
                            D ]D\  }	\  }
}|
|k    r|
                                r|                                rt          ||	<   Bd} |r nPt          |j                  D ] \  }	}||	                             |           !|                    |j                   t#          |          }|rJt          t          j                  }|d                             ||gt&          t(          gd	d	g||d
          S g }|D ]&}t#          |          }|                    |           '|d                             ||||d          S )aL  Accepts a list of function signatures and attempts to combine them together into a
        new CallableType consisting of the union of all of the given arguments and return types.

        If there is at least one non-callable type, return Any (this can happen if there is
        an ambiguity because of Any in arguments).
        zTrying to merge no callablesc              3  @   K   | ]}t          |t                    V  d S r   r   r   r  s     r   r   z@ExpressionChecker.combine_function_signatures.<locals>.<genexpr>5  s,      >>1:a..>>>>>>r   r  r   r   c                    g | ]}g S r   r   rr  s     r   r{  zAExpressionChecker.combine_function_signatures.<locals>.<listcomp>H  s    %U%U%UQb%U%U%Ur   FTN)r  r  r  r?  r  r  )r  r  r?  r  r  )r   r   r   r5  r   r  #merge_typevars_in_callables_by_namer  r  r  r  rz  r  ra  r2   r  r?  r   r  r3   r4   )r  r   	callablesr  r&  	new_kindsnew_returnstoo_complexrj  rv  new_kindtarget_kindr  union_returnr  
final_args	args_listr`  s                     r   r  z-ExpressionChecker.combine_function_signatures-  s    444444>>>>>>> 	391222-u55	y>>QQ<  C9MM	9%U%U%IaL<R8S8S2T2T%U%U%U1/00	"$ 	0 	0F 9~~V%5!6!666".7IvGW8X8X.Y.Y  **Hk{**++-- +2K2K2M2M #*IaLL"&K #F$455 ( (3""3''''v////,[99 		)011CQ<--*#Y/,%# .    
! 	( 	(I,Y77Hh''''|)) ! * 
 
 	
r   c           	     `   t          |||j        |j        fd          }| j                                        5  |                     ||||d          s	 ddd           dS 	 ddd           n# 1 swxY w Y   dd}	 |                     ||||||           dS # t          $ r Y dS w xY w)z^Determine whether arguments could match the signature at runtime, after
        erasing types.c                    |          S r   r   r  s    r   rw  z?ExpressionChecker.erased_signature_similarity.<locals>.<lambda>  s    PYZ[P\ r   NFr  r   original_ccaller_typer  r:   r  r^  rK  r  r  r   rH  r  rI  rD   r  r   r  c
                4    t          | |          st          d S r   )arg_approximate_similarityr   )
r  r  r  r  r^  r  r  rH  rI  r  s
             r   r  z@ExpressionChecker.erased_signature_similarity.<locals>.check_arg  s'     .k;GG   r   )rI  r  T)r  r   r  r   r  r:   r  r   r^  rK  r  rK  r  r   rH  r  rI  rD   r  rD   r   r  )r   r  r  r  r;  r  r  r   )	r  r  r  r  ru  r  rI  r}  r  s	    `       r   r  z-ExpressionChecker.erased_signature_similarity  sg    2y&"2F4DF\F\F\F\
 
 X##%% 	 	,,	9i9I4   	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 		 	 	 	"	%% # &    4 	 	 	55	s#   A11A58A5B 
B-,B-r"  c                H    t          j        ||| j        j        ||          S )z=Simple wrapper around mypy.applytype.apply_generic_arguments.r!  )r   r$  r  incompatible_typevar_value)r  r  r   rI  r"  s        r   r$  z)ExpressionChecker.apply_generic_arguments  s2     0H/-
 
 
 	
r   c                D   |                      |           t          |          }t          |t                    r6t          t          j        |          t          t          j        |          fS t          t          j                  t          t          j                  fS )Nr	  )r  r   r   r   r   r  r5  )r  ru  r  s      r   r  z%ExpressionChecker.check_any_type_call  s    --d333 ((fg&& 	T	2vFFF	2vFFF 
 9122GI<R4S4SSSr   c                      j                                         5   fd|                                D             }d d d            n# 1 swxY w Y   t          d |D                       |fS )Nc           	     B    g | ]}                     |          S r   )r  )r   subtyper  r  ru  rI  r  s     r   r{  z6ExpressionChecker.check_union_call.<locals>.<listcomp>  s=        y'9MM  r   c                    g | ]
}|d          S r0  r   )r   r  s     r   r{  z6ExpressionChecker.check_union_call.<locals>.<listcomp>  s    &A&A&A#s1v&A&A&Ar   )r  disable_type_namesr  r   )r  r  ru  r  r  rI  resultss   ` ```` r   r  z"ExpressionChecker.check_union_call  s     X((** 	 	       %4466  G	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 &&A&A&A&A&ABBFKKs   %AAAr  c                    | j         j                            t          |                     |                     ||          }|                     ||          }| j                             |j        |           |S )z'Visit member expression (of form e.id).)r  r&  r   r   analyze_ordinary_member_accessr(  warn_deprecatedr   )r  r$  r  r*  r+  s        r   visit_member_exprz#ExpressionChecker.visit_member_expr  sm    ##$9!$<$<===44Q	BB//6::  +++r   r4  c                
   |j         |                     |          S |                     |j        | j                  }|j        }d}t          |t                    r&t          |j        t                    r|j        j	        }t          |t                    r3t          |j        t                    r|j        j        p|j        j        }nd}t          |j        |||dd|| j        |                                 |||          }|S )zAnalyse member expression or member lvalue.

        An rvalue can be provided optionally to infer better setter type when is_lvalue is True.
        Nrm  F)	r  r  r  r  r  r  module_symbol_tablerJ  r4  )rm  r'  rf  r   r  r   r]   r   rT   rW  ro   rJ  is_clsr   r;  r  rO  )	r  r$  r  r4  r  rh  r!  rJ  member_types	            r   r  z0ExpressionChecker.analyze_ordinary_member_access  s	    6((+++ !KK$.KIIM6D"&$(( 6Z	8-L-L 6&*io#$((  Z	3-G-G   )+?ty/?/#!+H#'#:#:#<#<$7  K r   	base_typec                `    t          |||ddd|| j        |                                 	  	        S )z}Analyse member access that is external, i.e. it cannot
        refer to private definitions. Return the result type.
        Fr  )r   r  rO  )r  r  r$  rI  s       r   analyze_external_member_accessz0ExpressionChecker.analyze_external_member_access  sD     %##6688

 

 

 
	
r   c                6    t          | j        d                   S )Nr0  )r   r  r"  s    r   rO  z$ExpressionChecker.is_literal_context$  s    #D$5b$9:::r   r  r   fallback_namec                    |                      |          }|                                 rt          ||          S |                    t          |||j        |j                            S )az  Analyzes the given literal expression and determines if we should be
        inferring an Instance type, a Literal[...] type, or an Instance that
        remembers the original literal. We...

        1. ...Infer a normal Instance in most circumstances.

        2. ...Infer a Literal[...] if we're in a literal context. For example, if we
           were analyzing the "3" in "foo(3)" where "foo" has a signature of
           "def foo(Literal[3]) -> None", we'd want to infer that the "3" has a
           type of Literal[3] instead of Instance.

        3. ...Infer an Instance that remembers the original Literal if we're declaring
           a Final variable with an inferred type -- for example, "bar" in "bar: Final = 3"
           would be assigned an Instance that remembers it originated from a '3'. See
           the comments in Instance's constructor for more details.
        )r  r~  )r  r~  r@  rA  )rP  )r8  rO  r   r  r@  rA  )r  r  r(  r_  s       r   rQ  z)ExpressionChecker.infer_literal_expr_type'  sx    " oom,,""$$ 	US9999$$!,#CHSZ" " " %   r   leftr   rightc                    t          |j                  rt          |j                  rJ t          |j        |j        z   |                     d                    S )z$Concatenate two fixed length tuples.r  )r   r~  )r   r   r   r8  )r  r*  r+  s      r   concat_tupleszExpressionChecker.concat_tuplesB  sZ    '
33Y8KEK8X8XYYY*u{*T__EU5V5V
 
 
 	
r   rO   c                8    |                      |j        d          S )z(Type check an integer literal (trivial).builtins.intrQ  r  r  r$  s     r   visit_int_exprz ExpressionChecker.visit_int_exprI      ++AG^DDDr   rc   c                8    |                      |j        d          S )z&Type check a string literal (trivial).r*  r0  r1  s     r   visit_str_exprz ExpressionChecker.visit_str_exprM  r3  r   r>   c                8    |                      |j        d          S )z%Type check a bytes literal (trivial).r   r0  r1  s     r   visit_bytes_exprz"ExpressionChecker.visit_bytes_exprQ  s    ++AG5EFFFr   rK   c                ,    |                      d          S )z%Type check a float literal (trivial).zbuiltins.floatr8  r1  s     r   visit_float_exprz"ExpressionChecker.visit_float_exprU  s    /000r   rB   c                ,    |                      d          S )zType check a complex literal.zbuiltins.complexr9  r1  s     r   visit_complex_exprz$ExpressionChecker.visit_complex_exprY  s    1222r   rH   c                ,    |                      d          S )zType check '...'.zbuiltins.ellipsisr9  r1  s     r   visit_ellipsisz ExpressionChecker.visit_ellipsis]  s    2333r   rX   c                F   |j         r|                     |j                   S |j        dk    s|j        dk    r|                     ||          S |j        dk    r/t	          |j        t                    r|                     |          S |j        dk    r~t	          |j        t                    r%| j	        
                    |j        |j                  S t	          |j        t                    r%| j	        
                    |j        |j                  S |                     |j                  }t          |          }t	          |t                    r|j        dk    r|j        j                            d          }|r|j        dk    rt          |                     |j                            }t	          |t                    r`|j        j                            d          }|>t'          |j                  t'          |j                  |                     ||          S nt,          | j        j        j        v rt	          |t4                    r| j                            |          r|j                            d          }||j        j        j        d
k    rwt'          |j                  c| j                            ||          }| j                            d
|g          }|                    |j        t?          |          gz             S t@          }	|j        dk    rtC          |d          rCt          |                     |j                            }t	          |tD                    rtF          }	t	          |tD                    r>t          |                     |j                            }tC          |d          rtH          }	t,          | j        j        j        v r|j        dk    rt	          |t4                    r|j        j        d
k    rt          |                     |j                            }t	          |t                    rU|j        j        j        d
k    r@t'          |j                  ,|                    t?          |          g|j        z             S |j        tJ          j&        v rtJ          j&        |j                 }
|	tN          j(        u s|	tN          j)        u r/| *                    |
||j        ||	tN          j(        u           \  }}nh|	tN          j+        u rK| *                    tJ          j,        |
         |                     |j                  |j        |d          \  }}nt[          |	           ||_.        |S t_          d|j                   )z(Type check a binary operator expression.andor*%+__add__zbuiltins.tuple.__add____radd__Nr  r  |rR  )r$  r  rI  allow_reverseFzUnknown operator )0rc  rf  opcheck_boolean_opr   r*  rR   check_list_multiplyr>   r  check_str_interpolationr+  rc   r   r   partial_fallbackr   r  r   r   r   r-  rr   r  r  enable_incomplete_featurer   type_is_iterableiterable_item_typer[  r  r   r  r   r   r  r	  r   
op_methodsr  r  r  check_opr  reverse_op_methodsr   method_typeRuntimeError)r  r$  	left_typeproper_left_typeleft_add_methodproper_right_typeright_radd_methodri  r  use_reversemethodr*  rT  s                r   visit_op_exprzExpressionChecker.visit_op_expra  sF   : 	+;;qz***45==ADDLL((A...43;;:afh77;++A...43;;!&),, T*BB1617SSS!&'** T*BB1617SSSKK''	*955&	22 	qts{{.?DHHSSO ?#;?W#W#W$3DKK4H4H$I$I!/;; (9(J(O(S(ST^(_(_%(0 00@0FGGO23D3JKKS#'#5#56FHY#Z#ZZ'48+;+UUU"#4h?? V112CDD V
 ):(>(B(B:(N(N%)1,=BKO___/0@0FGGO$(H$?$?@QST$U$U	!%!<!<=MPY{![![/=="2"8Jv<N<N;O"O  >      #643;; !1?CC 5 %4DKK4H4H$I$I!/?? 5"4K*M:: 4 %4DKK4H4H$I$I!$%6HH 4"3K$("2"LLL /:: $)26FFF$3DKK4H4H$I$I!0)<<):?HL\\\+,=,CDDL,::)*:;;<?P?VV ;    49''')!$/Fj000K:CS4S4S&*mm'"-1C"C '4 ' '# 
 111&*mm08"kk!'22"' '4 ' '# [)))'AMM91499:::r   rA   c                $   d}t          |j        |j        dd         |j                  D ]_\  }}}|                     |          }|dk    s|dk    ra|                     |          }||                     |          }t          |          }|g}t          |t                    r!t          |	                                          }| 
                                }	g }
g }d}d}|D ]8}| j                            d          5 }|                     d||gt          g||	          \  }}| j                            |          }ddd           n# 1 swxY w Y   t          |t"                    rd}|                                r!|                     |          r| j                            d          5 }| j                            ||          \  }}ddd           n# 1 swxY w Y   |                                r0| j                            |                                           d}Mt/          |gt0          j        gdg| 
                                |                     d
                    }|j                            |           |                    |           |                                s3|r1|
                    |           |j                            |           
| j                            |                                           d}:|s|st          j        |          }t;          ||          sk|
s| j                            d|||           nt          j        |
          }|                     |||d          r| j                            ||d|           n|t          j         v rt          j         |         }tC          | j        j"                  5 }| #                    ||||d          \  }	}|j                            |           ddd           n# 1 swxY w Y   |                                sj|dv rf|                     |          }|                     ||          r;tI          |          }tI          |          }| j                            ||d|           n|dk    s|dk    r|                     |          }| 
                                }	|                     ||          r;tI          |          }tI          |          }| j                            ||d|           |j                            d           ntK          d|           ||	}JtM          j'        ||	          }a|J |S )zType check a comparison expression.

        Comparison expressions are type checked consecutive-pair-wise
        That is, 'a < b > c == d' is check as 'a < b and b > c and c == d'
        Nr   inznot inFTsave_filtered_errors__contains__)r\  r$  ru  r  rI  r  r/  )original_containerprefer_literal	container)rH  )z==z!=equalityiszis notidentityzUnknown comparison operator )(r  operandsr   rf  find_partial_type_ref_fast_pathr   r   r   r  r  	bool_typer  r;  check_method_call_by_namer2   r  analyze_container_item_typer   r  r  -analyze_iterable_item_type_without_expression
add_errorsfiltered_errorsr   r   r8  method_typesr  r  r}   unsupported_operand_typesdangerous_comparisonrQ  r!   errorsrR  r  rU  r   
join_types)r  r$  r*  r*  r+  operatorrV  
right_type
item_typesr  container_typesiterable_types
failed_outencountered_partial_typeri  container_errorsr  rT  	cont_typeiterable_errorsitertypeiterable_typecontainer_typer\  r  s                            r   visit_comparison_exprz'ExpressionChecker.visit_comparison_expr  s    # &)QZ^Q[%Q%Q F	= F	=!D%D))I48x#7#7 "AA%HH
%!%U!3!3J,Z88
.8\
j)44 C!%j&?&?&A&A!B!BJ!^^--
.0-/"
+0(!+ 3* 3*I //T/JJ TN^)-)G)G#1&/"&'.i$%*4 *H * *; %)H$H$H$S$S	T T T T T T T T T T T T T T T ")[99 !*370(7799* --i88	* "X333NN Ra*.(*`*` )1+ +KAx               +99;; < H//0O0O0Q0QRRR)-JJ*6!*!&!% $ 0 0 $0C D D+ +K N11+>>>*11(;;;;-<<>> *9 *'..y999--k::::++,<,L,L,N,NOOO%)

/ "
 "$-$8$H$HM%i?? ". " H>>tYPZ\]^^^^-6-A/-R-RN#88 ) .3=/4	  9     " !% = =$-~{A!" !" !" Y111"-h7!$(/22 7a.2mm	5!4 /< / /+J N))+666	7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 '')) \h,.F.F!%U!3!3J00JGG \$7	$B$B	%8%D%D
55iZYZ[[[T!!X%9%9![[//
!^^--
,,Y
CC X 3I > >I!4Z!@!@JH11)ZUVWWW%%d++++"#L(#L#LMMM ~#<<!!!s7   A EEE9G$$G(+G(.8P22P6	9P6	c                *   t          |t                    sdS t          |j        t                    ra|                     |j        |          }t          |t
                    r1|j        *| j                            |t          |                     |S dS )zIf expression has a partial generic type, return it without additional checks.

        In particular, this does not generate an error about a missing annotation.

        Otherwise, return None.
        N)
r   r]   r   ro   r6  r   r   r  r  r   )r  r   r*  s      r   rj  z1ExpressionChecker.find_partial_type_ref_fast_pathc  s     $(( 	4di%% 	))$)T::F&+.. 6;3J##D*<V*D*DEEEtr   T)rc  
seen_typesrd  rc  r  set[tuple[Type, Type]] | Nonerd  c                  | j         j        j        sdS |t                      }||f|v rdS |                    ||f           t          ||f          \  }}t          |d          st          |d          rdS |rt          |          }t          |          }| j         j        	                                rdS t          |t                    st          |t                    rdS t          |t                    rGt          |t                    r2t          |          }t          |          }t          ||f          \  }}|r t          |          rt          |          rdS t          |t                    rt          |t                    r|j        j        }|j        j        }|t$          v rq|t$          v rh| j                             d          }t)          ||          }t)          ||          }|                     |j        d         |j        d         |          S |j                            d          r|j                            d          r| j                             d          }	t)          ||	          }t)          ||	          }|                     |j        d         |j        d         |          p-|                     |j        d         |j        d         |          S |d	v r4||k    r.|                     |j        d         |j        d         |          S |t0          v r|t0          v rdS t          |t2                    rKt          |t2                    r6t          |j        t6                    rt          |j        t6                    rdS t          |t2                    rFt          |t                    r1|j        j        j        d
k    r|j                            d          rdS t          |t2                    rFt          |t                    r1|j        j        j        d
k    r|j                            d          rdS t;          ||d           S )a  Check for dangerous non-overlapping comparisons like 42 == 'no'.

        The original_container is the original container type for 'in' checks
        (and None for equality checks).

        Rules:
            * X and None are overlapping even in strict-optional mode. This is to allow
            'assert x is not None' for x defined as 'x = None  # type: str' in class body
            (otherwise mypy itself would have couple dozen errors because of this).
            * Optional[X] and Optional[Y] are non-overlapping if X and Y are
            non-overlapping, although technically None is overlap, it is most
            likely an error.
            * Any overlaps with everything, i.e. always safe.
            * Special case: b'abc' in b'cde' is safe.
        FN__eq__ztyping.AbstractSetr   )r  r  r   )rO  r  r   r   )ignore_promotions)r  r  strict_equalityr   r   r   r   r  r  !is_unreachable_warning_suppressedr   r   r   r   has_bytes_componentr   r   r   r   r  r+   rs  ru  r  r   r   r  r   r~  r,   )
r  r*  r+  rc  r  rd  	left_name
right_nameabstract_setabstract_maps
             r   rs  z&ExpressionChecker.dangerous_comparisons  s   0 x/ 	5J%=J&&5e}%%%&e}55e
 !x00 	4I%QY4Z4Z 	5 	/
 't,,D'..E8?<<>> 	 5dH%% 	E8)D)D 	5dI&& 	::eY+G+G 	:"4((D#E**E*D%=99KD%	#$677	 $D))	 5dH%% 	*UH*E*E 		*I,J888"===#x778LMM0|DD1%FF00IaL%*Q-J 1    ##$455 %*:M:MN^:_:_ #x778HII0|DD1%FF00IaL%*Q-J 1   c..ty|UZ]Wa.bbc AAAjT]F]F]00IaL%*Q-J 1    999j+? ? udK(( 	Z{-K-K 	$*d++ 
5;0M0M udK(( 	Zx-H-H 	}!*.>>>5:CVCV$D D> ue[)) 	jx.H.H 	~"+/???DIDVDV$E E? u'euMMMMMr   r\  c                   |p|}t          |          }t          |t                    r|                     ||||||          S t	          |||ddd||| j        |                                 
  
        }|                     ||||||          S )zType check a call to a named method on an object.

        Return tuple (result type, inferred method type). The 'original_type'
        is used for error messages.
        FT)r  r  r  r  r  r  r  )r   r   r   check_union_method_call_by_namer   r  rO  check_method_call)r  r\  r$  ru  r  rI  r  rT  s           r   rl  z+ExpressionChecker.check_method_call_by_name  s     &2#I..	i++ 	77	4G]   ,'#6688
 
 
 %%fidIW^___r   c           
     d   g }g }|                                 D ]z}	| j                                        5  |                     ||	||||          \  }
}ddd           n# 1 swxY w Y   |                    |
           |                    |           {t          |          t          |          fS )a  Type check a call to a named method on an object with union type.

        This essentially checks the call using check_method_call_by_name() for each
        union item and unions the result. We do this to allow plugins to act on
        individual union items.
        N)r  r  r  rl  r  r   )r  r\  r$  ru  r  rI  r  r  meth_resr_  r  	meth_items               r   r  z1ExpressionChecker.check_union_method_call_by_name  s     !++-- 	' 	'C ,,..  "&"@"@Cy'=# #i               JJtOOI&&&&$S))+@+J+JJJs   AA"	%A"	rT  c                    |                      ||          }||nd}|                     ||||||          }|                     ||||||          S )zType check a call to a method with the given name and type on an object.

        Return tuple (result type, inferred method type).
        Nr  r  )r  r  r  )	r  r  r$  rT  ru  r  rI  r  rH  s	            r   r  z#ExpressionChecker.check_method_call0  s     ,,YDD#0#<ii$ 00;ik 1 
 
 '!  
 
 	
r   op_namerV  	left_exprrw  
right_exprc           
         d fd}dd}t          |          }t          |          }t          |t                    rt          t          j        |          }	|	|	fS t          |t                    rt          t          j        |          }	|	|	fS t
          j        |         }
 |||          } ||
|          }|t
          j        v rt          ||          r||||fg}nt          ||          rut          |t                    r`t          |t                    rK|j        j        |j        j        j        |j        u s' |||           |||
          k    r|
|||f||||fg}n||||f|
|||fg}d |D             }g }g }|D ]l\  }}}} j                            d          5 }                     ||||gt           g          }d d d            n# 1 swxY w Y   |                                r=|                    |                                           |                    |           t          |t                    rt          |j                            |          x}t*                    ry|j        D ]q}t          |t.                    rZt          |j        j        x}t2                    r9t5          |          |d         k    r  j                            |j                   r|c S t          |t                    r|j        j        s!t          |t                    r)|j        j        rt          t          j                  }	|	|	fS |s j                            d          5 }                     |||gt           g          }d d d            n# 1 swxY w Y   |                                r=|                    |                                           |                    |           n|S  j                             |d                    tC          |          dk    r|d         S t          t          j"                  }||f}|S )Nr  r  r$  r   r   r  c                (                        ||           sdS j                                        5 }t          | |ddd|j                                        	  	        }|                                rdn|cddd           S # 1 swxY w Y   dS )zYLooks up the given operator and returns the corresponding type,
            if it exists.NFT)	r;  r_  r  r  r  r  rI  r  r  )
has_memberr  r;  r   r  rO  r  )r  r$  r  r  rI  r  s       r   lookup_operatorz>ExpressionChecker.check_op_reversible.<locals>.lookup_operatorW  s     ??9g66 t'')) >Q. !#" $"+#'+'>'>'@'@
 
 
  !//11=ttv> > > > > > > > > > > > > > > > > >s   ABBBr_  r   r  r  c                j    | j         j        D ]%}|j                            |          r	|j        c S &dS )a  Returns the name of the class that contains the actual definition of attr_name.

            So if class A defines foo and class B subclasses A, running
            'get_class_defined_in(B, "foo")` would return the full name of A.

            However, if B were to override and redefine foo, that method call would
            return the full name of B instead.

            If the attr name is not present in the given class or its MRO, returns None.
            N)r   r  rW  r  r   )r_  r  clss      r   lookup_definerz=ExpressionChecker.check_op_reversible.<locals>.lookup_definerp  sE     x| ( (9==++ (<'''(4r   r	  c                (    g | ]\  }}}}|	||||fS r   r   )r   narI  objr  s        r   r{  z9ExpressionChecker.check_op_reversible.<locals>.<listcomp>  s0    ```+=BCQSQ_RS#&Q_Q_Q_r   Tr`  r   r   )r  r  r$  r   r   r  )r_  r   r  r  r   r  )#r   r   r   r   r  r   rS  op_methods_that_shortcutr|   r}   r   r   alt_promoter  r;  r  r2   r  r  rp  
get_methodrY   r   rE   r  r   r   r  r)  r  r5  rl  ro  r  r<  )r  r  rV  r  rw  r  rI  r  r  any_typerev_op_nameleft_opright_opvariants_rawvariantsrt  r  r;  r\  r  r  local_errorsr*  r  r  r_  	error_anys   `     `                    r   check_op_reversiblez%ExpressionChecker.check_op_reversibleN  s[   	> 	> 	> 	> 	> 	> 	>2	 	 	 	  $I..	$Z00
 i)) 	&y9iPPPHX%%j'** 	&y9jQQQHX%%
  27;!/'955"?;
;; i888\)U_=`=`8 %gy*EFLLz9--	9h//	 :x00	
 *6N.3zFFy'22nnZQ\6]6]]] h
I>'9j9LL '9j9h
I>L a```` &. 	 	"D&#s''T'BB ^l//c6C57)U\]]^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^**,, l::<<===v&&&&c8,, 	JH//555D7H2 2 	J !%
 J J&tY77J *$).+@3, O OJ !*#&) ; ; H55diIII
 y(++ 	&	0N 	&z8,,	&1;1P	& y566HX%%  	''T'BB l77Ywi               
 **,, l::<<===v&&&& F1I&&&w<<11:	 455I	)FMs$   *"GG	G	1!NN"%N"r  rH  c                ^   |r|g}t          |          }t          |t                    r.t          t	          |                                                    }|                     |          }g }g }	| j                                        5 }
|D ]Y}| 	                    ||t          |          ||          \  }}|                    |           |	                    |           Z	 ddd           n# 1 swxY w Y   |
                                s"t          |          }t          |	          }||fS ||fg}t          |          }t          |t                    r-fdt	          |                                          D             }g }g }	| j                            d          5 }
|D ]a}|D ]\\  }}| 	                    ||t          |          ||          \  }}|                    |           |	                    |           ]b	 ddd           n# 1 swxY w Y   |
                                r| j                            |
                                           |
                                d         }t          t!                                }|j        |_        |j        |_        t'          |          dk    r.t'          |          dk    r| j                            |           nat'          |          dk    r| j                            d	||           n0t'          |          dk    r| j                            d
||           t          |          }|                     t/          |	                    }||fS |                     |||gt2          g          S )zType check a binary operation which maps to a method call.

        Return tuple (result type, inferred operator method type).
        r(  )r  rV  r  rw  r  rI  Nc                6    g | ]}|t          |           fS )r(  )rf   )r   r  rI  s     r   r{  z.ExpressionChecker.check_op.<locals>.<listcomp>K  s;     " " " 8D':::;" " "r   Tr`  r0  r  LeftRight)r\  r$  ru  r  rI  )r   r   r   r  r   r  rf  r  r;  r  rf   r  r  r   ro  rp  r   r@  rA  r  "warn_both_operands_are_from_unionswarn_operand_was_from_unionr  r   rl  r2   )r  r\  r$  r  rI  rH  left_variantsrw  all_resultsall_inferredr  left_possible_typer*  r	  results_finalinferred_finalright_variantsright_possible_typer  r  recent_contexts       `                r   rR  zExpressionChecker.check_op  s     `	&KM'	22I)Y// X $%:9;S;S;U;U%V%V W WS))J
 KL'')) 2\*7 
2 
2&'+'?'? &"4"*+=w"O"O"O#-#& ' (@ ( ($FH  &&v... ''1111
22 2 2 2 2 2 2 2 2 2 2 2 2 2 2  ..00 5 5k B B!6|!D!D$n44  *3/0N(44J*i00 " " " " 5j6O6O6Q6Q R R" " "
 KL''T'BB 6l*7 6 6&;I 
6 
67+Z+/+C+C$*&8&./A7&S&S&S':'1$+ ,D , ,( $**6222$++H5555
666 6 6 6 6 6 6 6 6 6 6 6 6 6 6 **,, ##L$@$@$B$BCCC"2244R8!)(**!5!5&)h#(+
%}%%**s>/B/Ba/G/GH??OOOO''1,,H88Tb8cccc((A--H88^ 9    2+>>M!==>N|>\>\]]N .0011#U") 2   s&   AC66C:=C:,A%HH"%H"c                "   | j         d         }|                     |j        |          }t          |                     |j        |          d          }|j        dv sJ |j        rd}i }ng|j        ri d}}n[|j        dk    r#| j                            |j                  \  }}n-|j        dk    r"| j                            |j                  \  }}t          j
        | j        j        j        v r.|,|j        s%| j                            |j        |j                   | j                                        r.|,|j        s%| j                            |j        |j                   |                     ||j        |          }||t'                      S ||J |S ||J |S |j        dk    rt)          |          }	|j         }
n"|j        dk    rt-          |          }	|j         }
t1          |	t&                    r|S |
r|S t3          |	|g          S )z/Type check a boolean operation ('and' or 'or').r0  rN  )r@  rA  Nr@  rA  )r  rf  r*  r   rI  right_alwaysright_unreachabler  find_isinstance_checkr  REDUNDANT_EXPRr  enabled_error_codesr  redundant_left_operand should_report_unreachable_issuesunreachable_right_operandr+  analyze_cond_branchr   r   can_be_truer   can_be_falser   r   )r  r$  rI  r2  rV  expanded_left_typeleft_map	right_maprw  restricted_left_typeresult_is_lefts              r   rJ  z"ExpressionChecker.check_boolean_op  sU    #KK,,	<KK$$o
 
 t}$$$$> 	I-1H.0II  	I"$diHHTU]]"&("@"@"H"HIxxTT\\"&("@"@"H"HHi
  DH$4$HHH N ! H++AD!&999 H5577	>!' " H..qtQW===--iBTUU
	 1"$$$'''(((45==#-.@#A#A !3!??NNTT\\#,-?#@#@ !3!@@N*O<< 	M 	M(*>
)KLLLr   c                R   |                      |j                  }t          ||                     d                    r(|                      |j        | j        d                   }n|                      |j                  }|                     d||j        |          \  }}||_        |S )zzType check an expression of form '[...] * e'.

        Type inference is special-cased for this common construct.
        r/  r0  r  __mul__)rf  r+  r}   r8  r*  r  rR  rT  )r  r$  rw  rV  r*  rT  s         r   rK  z%ExpressionChecker.check_list_multiply  s    
 [[))
j$//."A"ABB 	, AF9J29NOOIIAF++I"mmIy!'1MM#r   r<   c                J   |                      |j                  }| j                            |j        |j                   | j                            |           t          |          s | j                            |j        |           |                     |j                   |S r   )	rf  r  r  check_assignmentrj  check_finalr#  r  rj  )r  r$  r  s      r   visit_assignment_exprz'ExpressionChecker.visit_assignment_expr  s    AG$$!!!(AG444Q(// 	1 H%000,,QX666r   rn   c                (   |                      |j                  }|j        }|dk    r5|                                 }| j                            ||j                   n5t          j        |         }|                     ||g g |          \  }}||_	        |S )z7Type check an unary operation ('not', '-', '+' or '~').not)
rf  r   rI  rk  r  check_for_truthy_typer   unary_op_methodsrl  rT  )r  r$  operand_typerI  r*  r\  rT  s          r   visit_unary_exprz"ExpressionChecker.visit_unary_expr  s    {{16**T;;>>++FH**<@@@@/3F"&"@"@WY[]_`"a"aFK'AMr   rN   c                    |                      |          }|                     ||          }t          |          }|                                 r#t	          |t
                    r|j        |j        }|S )zgType check an index expression (base[index]).

        It may also represent type application.
        )visit_index_expr_helperr(  r   rO  r   r   rP  )r  r$  r*  p_results       r   visit_index_exprz"ExpressionChecker.visit_index_expr  sw    
 --a00--a88"6**##%%	/8X..	/ )5.Fr   c                    |j         r|                     |j                   S |                     |j                  }|                     ||          S r   )rc  rf  rh  visit_index_with_type)r  r$  rV  s      r   r  z)ExpressionChecker.visit_index_expr_helper  sI    : 	+;;qz***KK''	)))Q777r   ProperType | Nonec                    j         }t          |          }                     |           t          |t                    r.t          d |j        D                       rt          |i           }t          |t                    r5p|t           fd|
                                D             d          S t          |t                    rF j                                        r,t          |t                    r                     ||          S                      |          }|g }|D ]}                     ||          }||                    |           0 j                            t&          j                   t          d |j        D                       r3                     |          }	 j                            d|	            t/          t0          j                  c S t          |          S                      ||          S t          |t6                    r!                     |j                   d         S t          |t:                    r|                                r|                                j         r. !                    |                                j                   S  j        j"        j#        d	k    rK|                                j$        s|                                j%        d
k    r &                    d          S t          |tN                    r7 (                    |j)        d          s *                    |j)                  S t          |tV                    r%|j,        j%        dk    r &                    d          S  -                    d|j         gt\          g          \  }
}|_/        |
S )zAnalyze type of an index expression for a given type of base expression.

        The 'original_type' is used for error messages (currently used for union types).
        c              3  @   K   | ]}t          |t                    V  d S r   r  r   s     r   r   z:ExpressionChecker.visit_index_with_type.<locals>.<genexpr>  s=       4
 4
+-Jr:&&4
 4
 4
 4
 4
 4
r   c                >    g | ]}                     |          S r   )r  )r   r_  r$  r  r  s     r   r{  z;ExpressionChecker.visit_index_with_type.<locals>.<listcomp>!  s;        ..sA}EE  r   F)contract_literalsNc              3  @   K   | ]}t          |t                    V  d S r   r  r  s     r   r   z:ExpressionChecker.visit_index_with_type.<locals>.<genexpr>6  s,      RRQz!Z88RRRRRRr   zVariadic tuple can have length r   )   	   r  ztypes.GenericAlias__getitem__rK  r  )0rX  r   rf  r   r   r  r   r#   r   r   r  r  r9  ra   visit_tuple_slice_helpertry_getting_int_literalsvisit_tuple_index_helperr  r  r   TUPLE_INDEX_OUT_OF_RANGEmin_tuple_lengthr}  r   r   r<  nonliteral_tuple_index_helperr   visit_typeddict_index_exprr   r  r  r  visit_enum_index_exprr  python_versionr   r   r8  r   r  r  r  r   r   rl  r2   rT  )r  rV  r$  r  rX  nsoutr^  r  min_lenr*  rT  s   ` ``        r   r  z'ExpressionChecker.visit_index_with_type
  s    #I..	 	Ei++ 	3 4
 4
1:4
 4
 4
 1
 1
 	3 $Ir22Ii++ )	=)6YM(     (7799   #(    	9-- 	=$(2N2N2P2P 	= %++ G44YFFF..u55B~ 	= 	=A88AFFD'

4((((&6&OQRSSSRR)/RRRRR Z&*&;&;I&F&FG HMM*UG*U*UWXYYY&y';<<<<<,S11199)UKKK	=11 		=229agFFqII	<00 	=Y5J5J5L5L 	=$$&&. =11)2G2G2I2I17TUVVV!0F::%%''1 ;((**3FF';<<<i-- 	doo!=7
 7
 	 --i.CQVVV	8,, 	1HLa1a1a??#8999"&"@"@y17)gYQ^ #A # #FK (AMMr   c                H   t          |j                  }||                                S |j        |         }t          |t                    sJ t          |j        t                    r$|                                dz
  |j        j        z   S |                                dz
  S r  )r   r   lengthr   r   r   r   r  )r  r*  unpack_indexunpacks       r   r  z"ExpressionChecker.min_tuple_lengthV  s    *4:66;;== L)&*-----fk#344 	;;;==1$v{':::{{}}q  r   c           
        t          |j                  }|N|dk     r|t          |j                  z  }d|cxk    rt          |j                  k     rn n|j        |         S d S |j        |         }t          |t                    sJ t          |j                  }t          |t                    rKt          |j                  }t          |t                    sJ |j        j
        dk    sJ |j        d         }n6t          |t                    sJ |j        j
        dk    sJ |j        d         }|                     |          |                                z
  dz   }|dk    ry||                     |          k    rd S ||k     r|j        |         S t          j        |g|j        |dz   t!          ||z
  dz   |dz                      z   |j        |j                  S ||                     |          z  }|dk     rd S |||z   k    r|j        ||z
  dz            S t          j        |j        t'          ||          |         |gz   |j        |j                  S )Nr   r  r   r  )r   r   r  r   r   r   r   r   r  r   r   ru  r  r  r   r  maxr@  rA  r  )	r  r*  r^  r  r  unpackedboundmiddleextra_itemss	            r   r  z*ExpressionChecker.visit_tuple_index_helper`  s   *4:661uuS__$A''''DJ'''''z!}$4L)&*-----"6;//h 011 	& $H$899EeX.....:&*:::::Z]FFh11111=)-=====]1%F++D11DKKMMAAE66D))$//// t<z!}$'*\A-AOa4GXYIY0Z0ZZ[\		   	
T""4(((q554{***:a+o122#Js1l++l:;vhF	SWS^
 
 	
r   slicra   c           	        d g}d g}d g}|j         r4|                     |j                   }||                     ||          S |}|j        r4|                     |j                  }||                     ||          S |}|j        r4|                     |j                  }||                     ||          S |}g }	t          j        |||          D ]\  }
}}|                    |
|||                     d                    }|@| j	        
                    t          j        |           t          t          j                  c S |	                    |           t#          |	          S )Nr  r~  )begin_indexr  r  	end_indexstride	itertoolsproductslicer8  r  r  r   !AMBIGUOUS_SLICE_OF_VARIADIC_TUPLEr   r   r<  r  r   )r  rV  r  beginendr  	begin_rawend_raw
stride_rawr   br$  sr  s                 r   r  z*ExpressionChecker.visit_tuple_slice_helper  s   '+f%)F(,v 	55d6FGGI 99)TJJJE> 	33DNCCG99)TJJJC; 	 66t{CCJ!99)TJJJF (V<< 	 	GAq!??1aT__EU5V5V?WWD|.PRVWWWy344444LL$U+++r   rX  list[int] | Nonec                   t          |t                    r|j        gS t          |t                    ra|j        dk    r'|j        }t          |t                    rd|j        z  gS |j        dk    r$|j        }t          |t                    r|j        gS t          |                     |                    }t          |t                    r|j	        |j	        }t          |t                    r"t          |j        t                    r|j        gS t          |t                    rgg }t          |j                  D ]N}t          |t                    r5t          |j        t                    r|                    |j                   L dS |S dS )a  If the given expression or type corresponds to an int literal
        or a union of int literals, returns a list of the underlying ints.
        Otherwise, returns None.

        Specifically, this function is guaranteed to return a list with
        one or more ints if one the following is true:

        1. 'expr' is a IntExpr or a UnaryExpr backed by an IntExpr
        2. 'typ' is a LiteralType containing an int
        3. 'typ' is a UnionType containing only LiteralType of ints
        -r0  rD  N)r   rO   r  rn   rI  r   r   rf  r   rP  r   rK  r   r   r   r  )r  rX  operandr_  r  r  s         r   r  z*ExpressionChecker.try_getting_int_literals  s{    eW%% 
	+K= y)) 	+x3*gw// 0.//x3*gw// +#M?*dkk%0011c8$$ 	')=)I&Cc;'' 	Jsy#,F,F 	I;c9%% 	C(33    dK00  Z
C5P5P  JJtz****44Jtr   c                    |                      d||gt          g|           |                     |          }t          |t                    r| j                            d|g          S |S )Nr  r(  r  )rl  r2   union_tuple_fallback_itemr   ra   r  r[  )r  rV  rX  unions       r   r  z/ExpressionChecker.nonliteral_tuple_index_helper  sl    &&}i%7)]b&ccc..y99eY'' 	J8../?%IIIr   c                   g }|j         D ]}t          |t                    rt          |j                  }t          |t
                    rt          |j                  }t          |t                    r1|j        j        dk    r!|	                    |j
        d                    t          |	                    |           t          |          S )Nr  r   )r   r   r   r   r   r   r  r   r   r  ru  NotImplementedErrorr   )r  rV  r   r  r  s        r   r  z+ExpressionChecker.union_tuple_fallback_item  s    O 	# 	#D$
++ # /	 : :m-=>> O$3M4M$N$NM}h77.%*37GGGLL!3A!67777--T""""$U+++r   td_typesetitemtuple[Type, set[str]]c                   t          |t                    r
|j        g}n(t          |                     |                    }t          |t
                    rt          |j                  }n|g}g }t          |          D ]}t          |t                    r|j
        |j
        }t          |t                    rJt          |j        t                    r0|j        j        j        dk    r|                    |j                   | j                            ||           t'          t(          j                  t-                      fc S g }|D ]y}	|j                            |	          }
|
F| j                            ||	||           t'          t(          j                  t-                      fc S |                    |
           zt3          |          t-          |          fS )Nr   )r   rc   r  r   rf  r   r  r   r   r   rP  r   r  r~  r   r   r  r  $typeddict_key_must_be_string_literalr   r   r<  r   r  typeddict_key_not_foundr   )r  r  rX  r  	key_namesr_  	key_typesr  value_typeskey_namer  s              r   r  z,ExpressionChecker.visit_typeddict_index_expr  s    eW%% 	@II!$++e"4"455C#y)) "(,SY		 E	I,Y77 @ @h11 9h6O6['8H x55@"8>377@ !).7;KKK$$X^4444HAA'5QQQ"9#788#%%????! 	/ 	/H **844J!00(E7SSSy344cee;;;;"":....$[113y>>AAr   	enum_typec                    |                      d          }| j                            |                     |          ||dd           t	          |g           S )Nr*  zEnum index should be a stringzactual index type)r8  r  check_subtyperf  r   )r  r&  rX  rI  string_types        r   r  z'ExpressionChecker.visit_enum_index_expr  s\     !OON;;KK+	
 	
 	
 	2&&&r   r@   c                   |                      |j        t          t          j                  dd          }|j        }| j        j        }|j        rRt          |t          t          j                            s+t          ||          r| j
                            ||           |j        r+t          |          r| j
                            d||           t          || j        j        | j        j        | j
        |           |S )zType check a cast expression.Tr  r`  r  zTarget type of castr(  )rf  r   r   r   r5  r   r  r  warn_redundant_castsr|   r  redundant_castdisallow_any_unimportedr   unimported_type_becomes_anyr   is_typeshed_stub)r  r   source_typetarget_typer  s        r   visit_cast_exprz!ExpressionChecker.visit_cast_expr#  s   kkI !788"!	 " 
 
 i("(	7 gi6L.M.MNN	7 [+66	7
 H##K666* 	[/KK/X/X 	[H001FUYZZZ)48+DdhX\	
 	
 	
 	
 r   r;   c                   |                      |j        | j        d         dd          }| j        j        r|S |j        }t          |          }t          |t          j	        j
                  r|j        |j        }t          ||          sU| j                                        s | j                            d|j                   | j                            |||           |S )Nr0  Tr+  zC"assert_type" expects everything to be "Any" in unchecked functions)rf  r   r  r  rj  r   r   r   r  r   r   rP  r|   r9  r  r}  assert_type_fail)r  r   r1  r2  proper_source_types        r   visit_assert_type_exprz(ExpressionChecker.visit_assert_type_expr:  s    kkI*2."!	 " 
 
 8) 	i,[99)4:+>??	>"3?,=KK55 	F8//11 YI   H%%k;EEEr   r^   c                D   |j         t          k    r|j        J |                     |j        | j        d         d          }| j        j        sn| j                            ||j                   | j        	                                s | j        
                    d|j                   |                     |           |S | j        j        sJ|j        d |j        D             ni }| j                            ||           |                     |           t                      S )z$Type check a reveal_type expression.Nr0  Tr  r`  z9'reveal_type' always outputs 'Any' in unchecked functionsc                (    i | ]}|j         |j        S r   )r;  r   )r   var_nodes     r   r3  z7ExpressionChecker.visit_reveal_expr.<locals>.<dictcomp>j  s    SSShX]HMSSSr   )rm  r9   r   rf  r  r  rj  r  reveal_typer9  r}  check_reveal_importedlocal_nodesreveal_localsr   )r  r   revealed_typenames_to_typess       r   visit_reveal_exprz#ExpressionChecker.visit_reveal_exprT  s7   9##9((( KK	(9"(=QU (  M 81 1$$]DI>>>x3355 HMMSUYU^   **4000   81 1 '3 TS$BRSSSS  &&~t<<<**4000::r   c                   t           j        | j        j        j        vrd S d}|j        t          k    rd}n|j        t          k    r
|j        sd}nd S | j        	                    d| d|t           j                   |dk    rY| j        j        j
        dk    rdnd	}d
                    ||          }| j                            ||t           j                   d S d S )N r?  r<  zName "z" is not definedr  )r     typingtyping_extensionszXDid you forget to import it from "{module}"? (Suggestion: "from {module} import {name}"))moduler;  )r  UNIMPORTED_REVEALr  r  r  rm  r8   r9   is_importedr  r  r  r}  )r  r   r;  rH  hints        r   r=  z'ExpressionChecker.check_reveal_importeds  s    "$(*:*NNNF9%%"DDY+%%d.>% DDF5t555t%BYZZZ=   H,;wFFL_ ?fFf..  HMM$5+BMCCCCC ! r   tappri   c                `   t          |j        t                    rt          |j        j        t                    r|j        j        j        r|                                 S t          |j        j        |j        | j	        j
        |j        j        j        || j	        j                  }t          |          }t          |t                    r6t          |j        | j                  }|                     ||j        |          S t          |t(                    rQ|j        j        j        r@t          |j        j        | j                  }|                     ||j        j        |          S t          |t.                    r|                     |          S | j	        
                    t2          j        |           t7          t8          j                  S t          |                     |j                            }t          |t>          t@          f          rU|!                                s%| j	        
                    t2          j        |           |                     ||j        |          S t          |t6                    rt7          t8          j"        |          S t7          t8          j#                  S )a{  Type check a type application (expr[type, ...]).

        There are two different options here, depending on whether expr refers
        to a type alias or directly to a generic class. In the first case we need
        to use a dedicated function typeanal.instantiate_type_alias(). This
        is due to slight differences in how type arguments are applied and checked.
        r	  )$r   r   r]   r   r   python_3_12_type_aliastype_alias_type_typer   r   r  r  r  r  r   r   r   r   r8   apply_type_arguments_to_callableru  r   rM  r  r   r&  r   ONLY_CLASS_APPLICATIONr   r   r<  rf  r   r   r  r  r5  )r  rL  r  r  s       r   visit_type_applicationz(ExpressionChecker.visit_type_application  s2    di)) 	5j.S.S 	5y~4 300222)	
	&  D #4((D$)) 
5%diAA<<RDQQQD),, 51F1K1Z 5%d&;&@$/RR<<RAVA[]abbbD-00 5;;DAAA.EtLLLy3444 T[[3344b<455 	O>>## M.EtLLL88TZNNNb'"" 	F95"EEEEy-...r   aliasrh   c                <    |                      |j        |d          S )a  Right hand side of a type alias definition.

        It has the same type as if the alias itself was used in a runtime context.
        For example, here:

            A = reveal_type(List[T])
            reveal_type(A)

        both `reveal_type` instances will reveal the same type `def (...) -> builtins.list[Any]`.
        Note that type variables are implicitly substituted with `Any`.
        Tr1  )rF  r   )r  rS  s     r   visit_type_alias_exprz'ExpressionChecker.visit_type_alias_expr  s"     11%*%Z^1___r   )r3  r   r3  c                  |j         r|                                 S t          |j        t                    r%|j        j        rt          t          j                  S | j	        j
        j        o| j        }t          t          |g |j        |j        | j	        j
        || j        j                            }t          |t                    r?t'          |j        | j                  }|j        r|S |                     ||j        |          S t          |t2                    rDt5          |          j        j        dk    r't'          t5          |          j        | j                  S t          |t8                    r|                     |          S t          |t<                    rt?          ||j        |j                  S t          |t                    rt          t          j         |          S t          |tB                    r<|j"        r5| j	        j
        j#        dk    r | j	        $                    d|j%                  S |rt          t          j&                  S |                     d          S )a  Get type of a type alias (could be generic) in a runtime expression.

        Note that this function can be called only if the alias appears _not_
        as a target of type application, which is treated separately in the
        visit_type_application method. Some examples where this method is called are
        casts and instantiation:

            class LongName(Generic[T]): ...
            A = LongName[int]

            x = A()
            y = cast(A, ...)
        )disallow_anyr  r  r@  rA  r	  )r  
   ztypes.UnionTyperK  )'rN  rO  r   rj  r   invalidr   r   r<  r  r  disallow_any_genericsr  r   r   r@  rA  r  r  r   r   r8  r  rP  ru  r   r   r   r   r&  r   r   r  r   r  r  r[  r   r5  )r  rS  r2  r3  rW  r  r  s          r   rF  z/ExpressionChecker.alias_type_in_runtime_context  s:     ' 	/,,...elH-- 	1%,2F 	19/000
 x'=P$.
 )X]  

 

 dH%% 	: "$)T_==B} 	88TYLLLtY''	: 4  %.2BBB#N4$8$8$=tOOOm,, 	:77===h'' 	:DtyEEEEg&& 	:95$GGGGtY''
	:'
	:  /7::8../@$*MMM 7y5666??#8999r   r   c                `   |                                 r|                                j        j        }nt	          |j                  }t          |          }t          |j        |          D ]\  }}t          |t                    rt          t          |          t          t          t          t          f          sb| j                            dt!          || j        j                   |           t          t$          j                  gt)          |          z  c S |rt+          d |D                       st	          |          S |                                 sJ |                                }t-          |||j        |j                  }t3          || j        j        d          sFt5          || j        j        | j        j        d| j        j                   t	          |j                  }t;          d t=          |          D                       }	t)          |          |	z
  d	z
  }
||	         }t          |t>                    sJ tA          tC          |          |	|
          \  }}}t	          |          tE          t	          |          |j#                  gz   t	          |          z   S )
a  Handle directly applying type arguments to a variadic Callable.

        This is needed in situations where e.g. variadic class object appears in
        runtime context. For example:
            class C(Generic[T, Unpack[Ts]]): ...
            x = C[int, str]()

        We simply group the arguments that need to go into Ts variable into a TupleType,
        similar to how it is done in other places using split_with_prefix_and_suffix().
        zQCan only replace ParamSpec with a parameter types list or another ParamSpec, got c              3  @   K   | ]}t          |t                    V  d S r   r   r   r  s     r   r   z7ExpressionChecker.split_for_callable.<locals>.<genexpr>)  s-      MM1z!-=>>MMMMMMr   rX  T)empty_tuple_indexF)rW  r  c              3  J   K   | ]\  }}t          |t                    |V  d S r   r^  )r   rv  r  s      r   r   z7ExpressionChecker.split_for_callable.<locals>.<genexpr>9  s6      YYFQAGW9X9XYaYYYYYYr   r   )$r  r  r  r   r  r  r   r  r   r   r   r   r   r   r  r  r0   r  r   r<  r  r  r   r@  rA  r   r   r}  ru  nextrz  r   r   tupler   r   )r  r   ru  r2  varstvr  r  fakeprefixsuffixtvtstartr   r  s                  r   split_for_callablez$ExpressionChecker.split_for_callable  s    ==?? 	%==??'1DD$$D$T** 1;-- 
	G 
	GGB"m,, 	G!#C((:}g{*[  G HMMX3>sDHDT3U3UX X  
 $I$899:SYYFFFF 	3MMMMMMM 	::}}}}d#*EEE !tx}MMM 	#dhmTX]PTPXP`    	??DYYiooYYYYYTV#a'6l#/000009%++vvVVvsE{{iVc6HIIJJTRUYYVVr   r  c                    t          |          }t          |t                    r|                                r|                                j        j        }nt          |j                  }t          d |D                       }t          d |D                       }t                    |k     s!t                    t          |          k    r|s|                                r|                                j        dk    rt          t          t                     j                            d                    gt           gdgt          t                     j                            d                    |j        d|j        |j                  S  j                            |t          |          t                               t-          t.          j                  S                      |                     |                    S t          |t6                    r.|j        D ]}|                                r|                                j        j        }nt          |j                  }t          d |D                       }t          d |D                       }t                    |k     s t                    t          |          k    rT|sR j                            |t          |          t                               t-          t.          j                  c S t7           fd	|j        D                       S t-          t.          j                  S )
a{  Apply type arguments to a generic callable type coming from a type object.

        This will first perform type arguments count checks, report the
        error as needed, and return the correct kind of Any. As a special
        case this returns Any for non-callable types, because if type object type
        is not callable, then an error should be already reported.
        c              3  @   K   | ]}|                                  V  d S r   has_defaultr  s     r   r   zEExpressionChecker.apply_type_arguments_to_callable.<locals>.<genexpr>Z  s-      GGAMMOO 3GGGGGGr   c              3  @   K   | ]}t          |t                    V  d S r   r^  r  s     r   r   zEExpressionChecker.apply_type_arguments_to_callable.<locals>.<genexpr>[  s-      $X$XZ3C%D%D$X$X$X$X$X$Xr   r  rb  N)r;  
definition
bound_argsc              3  @   K   | ]}|                                  V  d S r   rm  r  s     r   r   zEExpressionChecker.apply_type_arguments_to_callable.<locals>.<genexpr>{  s-      #K#KA$7#K#K#K#K#K#Kr   c              3  @   K   | ]}t          |t                    V  d S r   r^  r  s     r   r   zEExpressionChecker.apply_type_arguments_to_callable.<locals>.<genexpr>|  s-      (\(\QA7G)H)H(\(\(\(\(\(\r   c           
     h    g | ].}                     |                    |                    /S r   )r$  rj  )r   r   ru  r2  r  s     r   r{  zFExpressionChecker.apply_type_arguments_to_callable.<locals>.<listcomp>  sP        00T5L5LRQUWZ5[5[]`aa  r   )r   r   r   r  r  r  r   r  r  ri  r  r  r   r   r  r8  r2   r~  rp  rq  r  incompatible_type_applicationr   r   r<  r$  rj  r   r   r5  )r  r  ru  r2  r   min_arg_counthas_type_var_tupler   s   ` ``    r   rP  z2ExpressionChecker.apply_type_arguments_to_callable@  sH    R  b,'' '	a~~ / NN,,1;		 ..	GGYGGGGGM!$$X$Xi$X$X$X!X!XD		M))SYYY-G-G( .H>>## (8(8(AEU(U(U ("4::tx/B/B7/K/KLLM 	!$t**dh.A.A'.J.JKK$#%=#%=	 	 	 	 66!3y>>3t99c   y3444//D4K4KBPTVY4Z4Z\_```b*%% 	h 9 9>>## 3 " 0 0 5 ?II $R\ 2 2I ##K#K#K#K#K K K%((\(\R[(\(\(\%\%\"II--TS^^1K1K, 2LH::%s9~~s4yy#   #9#788888      h     y-...r   rR   c                0    |                      |dd          S )z#Type check a list expression [...].rO  z<list>check_lst_exprr1  s     r   visit_list_exprz!ExpressionChecker.visit_list_expr  s    ""1ox@@@r   r`   c                0    |                      |dd          S )Nr   z<set>ry  r1  s     r   visit_set_exprz ExpressionChecker.visit_set_expr  s    ""1ng>>>r   ListExpr | SetExpr | TupleExprcontainer_fullnamec                   | j         d         }|rdS | j                            |d          }|t          |t                    r|ndS g }|j        D ]X}t          |t                    rt                      | j        |<    dS |                    | 	                    |                     Yt          j        |          }t          |          st                      | j        |<   dS | j                            ||g          }|| j        |<   |S )aY  
        Fast path to determine the type of a list or set literal,
        based on the list of entries. This mostly impacts large
        module-level constant definitions.

        Limitations:
         - no active type context
         - no star expressions
         - the joined type of all entries must be an Instance or Tuple type
        r0  N)r  r  r  r   r   r   rb   r   r  rf  r   r|  r   r  r[  )	r  r$  r  r2  rtr  r  vtcts	            r   fast_container_typez%ExpressionChecker.fast_container_type  s    # 	4##At,,>#B11;22t;G 	- 	-D$)) (0

"1%ttMM$++d++,,,, ((+B// 	$,JJDq!4X(();bTBB "1	r   tagc           
        |                      ||          }|r|S t          ddt          dd          g |                                 t	          t
          j                            }t          |gt          j	        gd g| j
                            ||g          |                     d          ||g          }|                     |d |j        D             d	 |j        D             |          d
         }t          |          S )NTr0  z<lst>	namespacer  r  r  defaultr/  r;  r  c                J    g | ] }t          |t                    r|j        n|!S r   )r   rb   r   r   rv  s     r   r{  z4ExpressionChecker.check_lst_expr.<locals>.<listcomp>  s-    IIIA
1h//6affQIIIr   c                h    g | ]/}t          |t                    rt          j        nt          j        0S r   )r   rb   r   r3   r2   r  s     r   r{  z4ExpressionChecker.check_lst_expr.<locals>.<listcomp>  s0    ]]]PQ
1h 7 7JennU]]]]r   r   )r  r   r   rH  r   r   from_omitted_genericsr   r   r3   r  r[  r8  r  r   r   )r  r$  r   r  r   rd  constructorr  s           r   rz  z ExpressionChecker.check_lst_expr  s$   $$Q11 	H w///((**I;<<
 
 
 #D^FH''2$77OO/00d
 
 
 ooIIIII]]UVU\]]]	
 

  1555r   rg   c                   t          |j                  }|4t          d |j        D                       t          |j                  k    S t          d |j        D                       dk    rdS t          d t	          |j                  D                       }t          |j                  t          |j                  k    o||k    S )Nc                <    g | ]}t          |t                    |S r   r   rb   r   r$  s     r   r{  z;ExpressionChecker.tuple_context_matches.<locals>.<listcomp>  s'    MMMaZ85L5LMMMMr   c                <    g | ]}t          |t                    |S r   r  r  s     r   r{  z;ExpressionChecker.tuple_context_matches.<locals>.<listcomp>  s'    AAAaAx)@)@AAAAr   r   Fc              3  J   K   | ]\  }}t          |t                    |V  d S r   r  )r   rv  lvs      r   r   z:ExpressionChecker.tuple_context_matches.<locals>.<genexpr>  s7      ``UQzRTV^G_G_`q``````r   )r   r   r  ra  rz  )r  r   r2  ctx_unpack_indexexpr_star_indexs        r   tuple_context_matchesz'ExpressionChecker.tuple_context_matches  s    .sy99# MM4:MMMNNRUVYV_R`R``` AA4:AAABBaGG5``i
.C.C`````4:#ci..0X5E5XXr   c                j    t           j        d                   }d}t          |t                    r> fdt	          |j                  D             }t          |          dk    r	|d         }n	 t          |t                    r                     |          r|j        }nX|rVt          |t                    rAt          |t                    sJ |j        r#|j        d         gt          j                  z  }d}|t          |          du}d}|pt           j        j        j        v }g }d}	t%          t          j                            D ]	}
j        |
         }t          |t&                    r|r+|sJ ||	         }t          |t(                    sJ |j        }nd}                     |j        |          }t          |          }t          |t                    rkt          |j                  |r                     dd          c S d	}|                    |j                   |r|	dz  }	|	t          |j                  z  }	|r|st          |t                    rw j                            |          r] j                            |          } j                            d|g          }|                    t)          |                     d	}                     dd          c S |r|	t          |          k    r                     |          }n!                     |||	                   }|	dz  }	|                    |           t=          t>          j                   }t          | j                            d|g                    }|rtC          |i           }|S )
zType check a tuple expression.r0  Nc                    g | ]D}t          |t                    r                    |          st          |t                    B|ES r   )r   r   r  r   r   )r   r   r$  r  s     r   r{  z6ExpressionChecker.visit_tuple_expr.<locals>.<listcomp>  sh     ! ! !q),,! 261K1KAq1Q1Q! %Q(ABB	!! ! !r   r   r   Fr  z<tuple>T)"r   r  r   r   r   r   r  r   r  r   r   r   ru  r   rr   r  r  rN  r  rb   r   r   rf  r   rz  rQ  rO  rP  r[  r  r   r   r5  r#   )r  r$  r  type_context_itemstuples_in_contextunpack_in_contextseen_unpack_in_itemsallow_precise_tuplesr   rz  rv  r  ctx_itemr2  ttri  r  fallback_itemr*  s   ``                 r   visit_tuple_exprz"ExpressionChecker.visit_tuple_expr  s    't'8'<==!lI.. 	! ! ! ! !),*<==! ! ! $%%**03 lI.. 	K43M3MaQ]3^3^ 	K!-!3 	K/>WXX 	KlH55555  K&2&7&:%;c!'ll%J" ") 34F G Gt S$b!48H8b!b 	 s17||$$ 4	! 4	!A71:D$)) 2! % ----1!4H%h
;;;;;"-CCC[[C00$R((b),, O*2844@/ 8 $(#6#6q:JI#V#VVVV370LL***( +Q S]]*+ %4H %%b(33 %8Q8QRT8U8U %(,(C(CB(J(JI%)X%@%@AQT]S^%_%_F!LLF););<<<370$  ..q2BINNNNN) Q#6H2I2I-I-IT**BBT+=a+@AABFAR    	 677&48../?-QQ
 
   	- ,,Fr   rF   c                   | j         d         }|rdS | j                            |d          }|t          |t                    r|ndS g }g }d}|j        D ]\  }}|t          |                     |                    }	t          |	t                    rC|	j        j	        dk    r3t          |	j                  dk    r|	j        d         |	j        d         f}t                      | j        |<    dS |                    |                     |                     |                    |                     |                     t          j        |          }
t          j        |          }t!          |
          rt!          |          st                      | j        |<   dS |r0|d         |
k    s|d         |k    rt                      | j        |<   dS | j                            d|
|g          }|| j        |<   |S )a~  
        Fast path to determine the type of a dict literal,
        based on the list of entries. This mostly impacts large
        module-level constant definitions.

        Limitations:
         - no active type context
         - only supported star expressions are other dict instances
         - the joined types of all keys and values must be Instance or Tuple types
        r0  NrR  r  r   r   )r  r  r  r   r   r   r   rf  r   r   r  ru  r   r  r   r|  r   r  r[  )r  r$  r2  r  r  r  stargsr  r  stktr  dts                r   fast_dict_typez ExpressionChecker.fast_dict_typeN  s    # 	4##At,,>#B11;22t;+/' 	2 	2JC{$T[[%7%788r8,, (O;;BG)) gaj"'!*5FF,4JJD&q)44DKK,,---dkk%001111 && ((,R00 	5QRT5U5U 	$,JJDq!4 	vayB&)r//$,JJDq!4X((2r(CC "1	r   typeddict_contextc                    |                      ||j        |d           }t          |          }t          |t                    r|                                S |                                S )N)r  r  rI  r  )r  r   r   r   r   r  )r  r$  r  rC  r?  s        r   "check_typeddict_literal_in_contextz4ExpressionChecker.check_typeddict_literal_in_context}  sn     ;;$QWaT < 
 
 #=11h.. 	,))+++ ..000r   c           
        |                      | j        d         |          }|rt          |          dk    r|                     ||d                   S |D ]}| j                                        5 }| j                                        5 }|                     ||          }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                                r| j        	                    |           |c S | j        
                    ||           |                     |          }|r|S t          ddt          dd          g |                                 t          t           j                            }t          d	d	t          d
d          g |                                 t          t           j                            }	g }
g }|j        D ] \  }}|F|
                    |           |                    | j                            d||	g                     Nt+          ||g          }|j        dk    r|j        |_        |j        |_        n|j        |_        |j        |_        |j        |_        |j        |_        |
                    |           |                    t5          ||	g|                     d                               t9          |t:          j        gt          |          z  dgt          |          z  | j                            d||	g          |                     d          d||	g          }|                     ||
t:          j        gt          |
          z  |          d         S )zoType check a dict expression.

        Translate it into a call to dict(), with provisions for **expr.
        r0  r   r   NKT<dict>r  r  VTr  r  rR  r/  r  ) find_typeddict_contextr  r  r  r  r;  r  r<  r  r  typeddict_context_ambiguousr  r   r   rH  r   r   r  r   r  r[  rg   r@  rA  end_line
end_columnr   r8  r   r   r2   r  )r  r$  typeddict_contextsr  r  tmapr?  r  r  r  ru  r!  r  r  tupr  s                   r   visit_dict_exprz!ExpressionChecker.visit_dict_expr  s(    "889J29NPQRR 	H%&&!++>>qBTUVBWXXX%7    !X++-- ]dh6M6M6O6O ]SW#FFqJ[\\H] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]%%'' $$T***H001CQGGG   ## 	I x000((**I;<<
 
 
 x000((**I;<<
 
 
 "$%'' 	^ 	^JC{E"""%%H//0RUWY[T\]]     e--8q=="xCH!$CJJ$zCH!&CJ$~!&!1C   %%iR$//JZ:[:[&\&\]]]] #]Oc.111FS(((H''"bBBOO/002h
 
 
 {D5=/CII2MqQQRSTTs6   0C
B-!C-B11C4B15CC	C		dict_exprlist[TypedDictType]c                2   t          |          }t          |t                    r|gS t          |t                    rZg }|j        D ]N}|                     ||          }|D ]3}|                     ||j        |          r|                    |           4O|S g S r   )r   r   r   r   r   r  r  r  )r  rI  r  r   r  item_contextsitem_contexts          r   r  z(ExpressionChecker.find_typeddict_context  s     "'**g}-- 	9++ 		E 3 3 $ ; ;D) L L$1 3 3L::$ioy  3 \222	3
 L	r   rP   c                   | j                             |d           |                     |          \  }}|sD| j         j                            t          t          j                             | j         j        	                    dd          5  | j         j
                            |          5  |j        j        dd         D ]}|                    | j                    |                     |                                d          }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |                     d	          }| j         j                                         t#          |||          S | j         j                            |j                   | j         j                            |          5  | j                             ||
           ddd           n# 1 swxY w Y   | j                             |                                          sb| j         j        	                    dd          5  |                     |                                d           ddd           n# 1 swxY w Y   | j                             |                                          }| j         j                                         t1          ||          S )zType check lambda expression.F)body_is_trivialTr   can_skipfall_throughNr0  rb  r/  )type_override)r  check_default_argsinfer_lambda_type_using_contextr  r  r   r   r5  r  frame_contextrK  push_functionbodyrf  r   r8  popr   r?  tscopefunction_scopecheck_func_itemr  r  replace_callable_return_type)r  r$  rU  r  stmtr?  r~  s          r   visit_lambda_exprz#ExpressionChecker.visit_lambda_expr  s   ##Au#==='+'K'KA'N'N$} 	IH!((1G)H)HIII --t!-LLI I,,Q//I I FK, * *DKK))))  ;;qvvxx4;HHI I I I I I I I I I I I I I I I I I I I I I I I I I I I I I ':;;HH!%%''' Hh777 H!(()?@@@//22 I I((-(HHHI I I I I I I I I I I I I I I8$$QVVXX.. BX_22Dq2QQ B BKKDKAAAB B B B B B B B B B B B B B Bx++AFFHH55HH!%%'''/xHHHs[    D-/AD
D-D	D-D	D--D14D1?G((G,/G, *I66I:=I:/tuple[CallableType | None, CallableType | None]c                >  	 t          | j        d                   }t          |t                    rFd t	          |                                          D             }t          |          dk    r|d         }|rt          |t                    sdS | j        j	        j
        sg 	|j        D ]<}d t          |          D             }	                    	fd|D                        =|                    t          |j        t#                                t%          |j                  	z             }nJt          |t#                                }t          |t(                    rt          |t                    sJ |}|                    |                     d	          
          }|j        |j        dS d |j        D             }|j        s|                                X|                    dt7          t8          j                  gt          |          z  ||j                                                  }t@          |v s	tB          |v r|dfS |j"        |k    r'| j        #                    tH          j%        |           dS |                    |j                  |fS )zTry to infer lambda expression type using context.

        Return None if could not infer type.
        The second item in the return type is the type_override parameter for check_func_item.
        r0  c                <    g | ]}t          |t                    |S r   r  r  s     r   r{  zEExpressionChecker.infer_lambda_type_using_context.<locals>.<listcomp>  s9       ZPQS_E`E`  r   r   r   NNc                D    g | ]}|j                                         |S r   )r  is_meta_var)r   rd  s     r   r{  zEExpressionChecker.infer_lambda_type_using_context.<locals>.<listcomp>1  s+    XXXBBEDUDUDWDWXRXXXr   c                    g | ]}|v|	S r   r   )r   rd  
extra_varss     r   r{  zEExpressionChecker.infer_lambda_type_using_context.<locals>.<listcomp>2  s#    "R"R"R"Rz=Q=Q2=Q=Q=Qr   )r?  r  r/  r  Nc                    g | ]	}|j         
S r   )rm  )r   r  s     r   r{  zEExpressionChecker.infer_lambda_type_using_context.<locals>.<listcomp>F  s    555#SX555r   F)is_ellipsis_argsr  r  r  )r  )&r   r  r   r   r   r  r  r   r  r  r  r  r   rQ  r  r    r?  r   r  r  r   r8  r  r  	argumentsr  r  r   r   r5  r  r  r3   r4   r  r  r   CANNOT_INFER_LAMBDA_TYPE)
r  r$  r2  r  r  	meta_varscallable_ctxr%  r  r  s
            @r   r  z1ExpressionChecker.infer_lambda_type_using_context  s    d/344c9%% 	# +C,>,>,@,@AA  I 9~~""l 	*S,77 	: x2 	& J} T TXX*;C*@*@XXX	!!"R"R"R"R	"R"R"RSSSS,,*3<FFs}--
: -  LL
 +3
==Jj*55^*ZQ]:^:^^^^%L $114??K^;_;_1``".,2F2R :55555	( 	CNN,<,<,H'55!&"9#9::;c)nnL#+**,,	 6  L y  I$:$:%%!Y..HMM*CQGGG: ))AK)@@,NNr   rd   c                `   |                      |          }t          |t                    r|\  }}n|S t          |          }|>| j                            t          j        |           t          t          j
                  S t          |          }|>| j                            t          j        |           t          t          j
                  S |j        }d}||v r|                    |          }nl| j        j                                        }	|	Lt!          ||	j                  r6|j        r/||j        j        v r!|j        j        }|                    |          }|U|j        r||k    r
|j        sd}n>| j                            t          j        |           t          t          j
                  S t+          |          |dz   k    r>| j                            t          j        |           t          t          j
                  S ||dz   d         D ]}
|j        |
j        v s|
|d         k    rq|j        r3|j        j        r'|
|d         k    rt          t          j                  c S t7          |j        |ddd||
|| j        |                                 
  
        c S J d            )	z+Type check a super expression (non-lvalue).N)is_classmethodr0  r   FT)
r;  r_  r  r  r  r  override_inforI  r  r  r  )_super_arg_typesr   rb  type_info_from_typer  r  r   UNSUPPORTED_ARG_1_FOR_SUPERr   r   r<  UNSUPPORTED_ARG_2_FOR_SUPERr  rX  rK  current_functionr   is_classr  r  !SUPER_ARG_2_NOT_INSTANCE_OF_ARG_1r  TARGET_CLASS_HAS_NO_BASE_CLASSr;  rW  r  r5  r   rO  )r  r$  r   	type_typeinstance_type	type_infoinstance_infor  rX  r\  rh  s              r   visit_super_exprz"ExpressionChecker.visit_super_expr^  s    %%a((eU## 	',$I}}L (	22	HMM*FJJJ9/000+M:: HMM*FJJJ9/000 IIi((EEX^4466F !&7fo' ' '! 6 1i16:55&*CIIi00E=)5!Y..!- / .PRSTTTy3444s88uqy  HMM*I1MMM9/000	$ 	 	Dv##ts2w6 ;af4 ;R #9#9:::::,%#! %"/"&'+'>'>'@'@      (7& 	$m###r   Type | tuple[Type, Type]c                
   | j                                         st          t          j                  S t          |j        j                  dk    r!|j        st          t          j	                  S | j         j
                                        r>| j                             t          j        |           t          t          j	                  S t          |j                  }t!          |          }| j         j
                                        }|J |j        r|j        d         j        j        p|}n| j                             t          j        |           t          t          j	                  S t,          |j        j        v r>| j                             t          j        |           t          t          j	                  S t3          |j        j                  t4          hk    r>| j                             t          j        |           t          t          j	                  S t          |j        j                  dk    r>| j                             t          j        |           t          t          j	                  S t          |j        j                  dk    rXt;          |                     |j        j        d                             }|                     |j        j        d                   }n>| j                             t          j        |           t          t          j	                  S tA          |t                    rD|j        r"t!          t          |j                            }nt          t          j!        |          S tA          |t                     r`|j"        }tA          |t                    rD|j        r"t!          t          |j                            }nt          t          j!        |          S tA          |t                     s]tA          |tF                    r|$                                s4| j%        &                    ||           t          t          j	                  S t;          |          }tA          |t                    r7|j        rt          |j                  }nt          t          j!        |          S tA          |t                     r`|j"        }tA          |t                    rD|j        r"t!          t          |j                            }nt          t          j!        |          S ||fS )a*  
        Computes the types of the type and instance expressions in super(T, instance), or the
        implicit ones for zero-argument super() expressions.  Returns a single type for the whole
        super expression when possible (for errors, anys), otherwise the pair of computed types.
        r   Nr   r  r	  )'r  r9  r   r   r;  r  callru  r  r<  rK  active_classr  r   %SUPER_OUTSIDE_OF_METHOD_NOT_SUPPORTEDr   r   r  r  variabler   (SUPER_ENCLOSING_POSITIONAL_ARGS_REQUIREDr3   r  SUPER_VARARGS_NOT_SUPPORTEDr   r2   SUPER_POSITIONAL_ARGS_REQUIRED#SUPER_WITH_SINGLE_ARG_NOT_SUPPORTEDr   rf  TOO_MANY_ARGS_FOR_SUPERr   r  r  r   r  r  %first_argument_for_super_must_be_type)r  r$  current_typer  r\  r  	type_iteminstance_items           r   r  z"ExpressionChecker._super_arg_types  sT    x++-- $	190111""6 5y3444,,.. 5.TVWXXXy3444 )00L$,\$:$:I X^4466F%%% 5&,&6q&9&B&G&W<.WYZ[[[y3444)))HMM*FJJJ9/000!""wi//HMM*I1MMM9/000""HMM*NPQRRR9/000""'AFKN(C(CDDI KKA77MMHMM*BAFFF9/000 i)) 	Uv Q$]16%:%:;;		y9iPPPP	8,, 	U!I)W-- U6 U (qv)>)> ? ?II"9#=)TTTT)X.. 	1y,//	14=4I4I4K4K	1 H::9aHHH9/000 (66mW-- 	Yv U -af 5 5y9mTTTTx00 	Y).M-11 Y6 Y$,]16-B-B$C$CMM"9#=-XXXX-''r   c                   	 | j                             d          }n*# t          $ r | j                             d          }Y nw xY wt          |          }g }|j        |j        |j        fD ]w}|rR|                     |          }| j                             |||t          j
                   |                    |           V|                    t                                 x| j                             d|          S )Nztyping_extensions.SupportsIndexr/  zbuiltins.slice)r  r8  rV  r   r  r  r  rf  r(  r   INVALID_SLICE_INDEXr  r   r[  )r  r$  supports_indexexpected	type_argsrX  r   s          r   visit_slice_exprz"ExpressionChecker.visit_slice_expr  s
   	A!X001RSSNN 	A 	A 	A!X00@@NNN	A%n55	mQ[!(; 	- 	-E -KK&&&&q(E;K;_```  ####  ,,,,x**+;YGGGs    $AArQ   c                :    |                      |j        dd          S )NrO  z<list-comprehension> check_generator_or_comprehension	generatorr1  s     r   visit_list_comprehensionz*ExpressionChecker.visit_list_comprehension  s$    44K*@
 
 	
r   r_   c                :    |                      |j        dd          S )Nr   z<set-comprehension>r  r1  s     r   visit_set_comprehensionz)ExpressionChecker.visit_set_comprehension  s$    44K)>
 
 	
r   rM   c                l   t          |j                  sXt          |j                  sDt          d |j        dd          D                       st          d |j        D                       rd}t                      g}nd}t                      t                      g}|                     ||d|          S )Nc              3  4   K   | ]}t          |          V  d S r   r   )r   sequences     r   r   z9ExpressionChecker.visit_generator_expr.<locals>.<genexpr>#  s+      RRh'11RRRRRRr   r   c              3  >   K   | ]}|D ]}t          |          V  d S r   r   )r   condlistconds      r   r   z9ExpressionChecker.visit_generator_expr.<locals>.<genexpr>$  s9      __(V^__d'--_______r   ztyping.AsyncGeneratortyping.Generatorz<generator>)additional_args)r  is_asyncr   r  	sequences	condlistsr   r	  )r  r$  r_  r  s       r   visit_generator_exprz&ExpressionChecker.visit_generator_expr  s     
OO	7#AK00	7 RR!+abb/RRRRR	7 __ak_____		7 *C+3::,OO$C'zz8::6O44sM? 5 
 
 	
r   genr  id_for_messagesr  list[Type] | Nonec                V   |pg }| j         j                            dd          5  |                     |           t	          ddt          dd          g |                                 t          t          j	                            }|g}t          |t          j        gd	g| j                             |||z             | j                             d
          ||g          }|                     ||j        gt          j        g|          d         cd	d	d	           S # 1 swxY w Y   d	S )z:Type check a generator expression or a list comprehension.Tr   r  r  r0  z<genexp>r  r  Nr/  r  )r  r  r  check_for_compr   r   rH  r   r   r  r   r   r2   r[  r8  r  r  )r  r  r  r  r  rd  tv_listr  s           r   r	  z2ExpressionChecker.check_generator_or_comprehension1  s    */RX_**Dq*II 	Z 	Z$$$ R:666 ,,..	 ?@@  B $&$G&++Iw7PQQ##$788$$  K ??;%-RUVVWXY/	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Zs   C+DD"%D"rG   c                    | j         j                            dd          5  |                     |           t	          ddt          dd          g |                                 t          t          j	                            }t	          d	d	t          d
d          g |                                 t          t          j	                            }t          ||gt          j        t          j        gddg| j                             d||g          | j                             d          d||g          }|                     ||j        |j        gt          j        t          j        g|          d         cddd           S # 1 swxY w Y   dS )z&Type check a dictionary comprehension.Tr   r  r  r0  r  r  r  r  r  NrR  r/  z<dictionary-comprehension>r  )r  r  r  r  r   r   rH  r   r   r  r   r   r2   r[  r8  r  r  r  )r  r$  ktdefvtdefr  s        r   visit_dictionary_comprehensionz0ExpressionChecker.visit_dictionary_comprehensionS  s   X_**Dq*II  	  	"""  R8444 ,,..	 ?@@  E  R8444 ,,..	 ?@@  E '.t++OeU^LL##$7881 %.  K ??aeQW-u}/Mq = 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	s   EFF
F'GeneratorExpr | DictionaryComprehensionc                &   t          |j        |j        |j        |j                  D ]h\  }}}}|r| j                            |          \  }}nx| j                            |          \  }}t          t          |          t                    r9t          |t                    r$|j        dk    rt          t          j                  }| j                            ||d|           |D ]}|                     |           | j                            |          \  }	}
|	r| j                            |	           t(          j        | j        j        j        v r;|	| j                            d|           |
| j                            d|           jdS )zCheck the for_comp part of comprehensions. That is the part from 'for':
        ... for x in y if z

        Note: This adds the type information derived from the condlists to the current binder.
        r  TNF)r  indicesr  r  r  r   analyze_async_iterable_item_typeanalyze_iterable_item_typer   r   r   rV   r;  r   r   r5  analyze_index_variablesrf  r  push_type_mapr  r  r  r  r  $redundant_condition_in_comprehension)r  r$  rX  r  
conditionsr  r  sequence_type	conditiontrue_map	false_maps              r   r  z ExpressionChecker.check_for_compw  s    69Iq{AK6
 6
 	W 	W1E8Z  
D#'8#L#LX#V#V ==#'8#F#Fx#P#P =}==OOD"5(33D 
c)) %,I,B$C$CMH,,UM4KKK' W W	I&&& '+h&D&DY&O&O#) 5H**8444'48+;+OOO'EEeYWWWW"*EEdIVVVW!	W 	Wr   rC   c                   |                      |j                   | j        d         }| j                            |j                  \  }}t
          j        | j        j        j        v rE|!| j	        
                    d|j                   n"| | j	        
                    d|j                   |                     ||j        ||          }t          t          |                    p|}|                     ||j        ||          }t           j                            || j        j                  sQ|}	t          t          |	                    p|	}
|t'          |
|          s|                     ||j        |
|          }n'||k    r|}	n|                     ||j        ||          }	t)          |          rt)          |	          s|}	t+          ||	g          }t-          |          rxt/          t          | j        d                   t0                    sKt3          j        ||	          }t          |          }t/          |t6                    r|j        j        dk    r|}|S )Nr0  FT)rI  r`  rU  )rf  r  r  r  r  r  r  r  r  r  redundant_condition_in_ifr  if_exprr   r   	else_exprr  r  rZ  r{   r   r   r#  r   r   r   ru  r   r   r   )r  r$  r`  r2  if_mapelse_mapif_typeif_type_fallbackfull_context_else_type	else_typeelse_type_fallbackr  alternativep_alts                 r   visit_conditional_exprz(ExpressionChecker.visit_conditional_expr  s   AF#  899!&AA48#3#GGG~225!&AAAA!224@@@**AIs>O + 
 
 /w/G/GHHSG "&!9!9ak3BS ": "
 "
 |227DH<LMM $	.I "5_Y5O5O!P!P!]T] {-0BC"H"H{ 22I.&7	 3   $$ /II 00("3	 1  I   677 	/@TU^@_@_ 	/.I)7I*>??$S)) 	"*D-b122I3
 3
 	" /'9==K#K00EeX.. "%*2EIZ2Z2Z!
r   r  dict[Expression, Type] | Nonesuppress_unreachable_errorsc                   | j         j                            dd          5  |e| j                            |          5  |                     |||           d d d            n# 1 swxY w Y   t                      cd d d            S | j                             |           |                     |||          cd d d            S # 1 swxY w Y   d S )NTr   r  )r;  r9  )r  r  r  r  r;  rf  r   r*  )r  r  r   rI  r`  r@  s         r   r  z%ExpressionChecker.analyze_cond_branch  s    X_**Dq*II 		` 		`{ X++:U+VV a aKK7N_K```a a a a a a a a a a a a a a a&((		` 		` 		` 		` 		` 		` 		` 		` H""3''';;t'M^;__		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		` 		`s;   C A%C%A)	)C,A)	-C
1CCCr  r  c                n   || j         v r| j         |         S d}| j        r#| j        st          j                    }d| _        d}| j                            |           | j        }|| _        	 |r-t          |t                    r| 
                    |d          }	n|r-t          |t                    r|                     |d          }	ns|r-t          |t                    r|                     |d          }	nD|r-t          |t                    r|                     |d          }	n|                    |           }	nR# t$          $ rE}
t'          |
| j        j        j        |j        | j        j        | j        j                   Y d}
~
nd}
~
ww xY w|| _        | j                                         |	J | j                            ||	           | j        j        j        r]|s[| j        j        sO| j                                        r6t=          |	          r'| j        j        s| j         !                    |	|           | j                                        r| j        j        rtE          tF          j$                  }n|	}|r5| j%        |j        xx         t          j                    |z
  z  cc<   d| _        |S )zType check a node in the given type context.  If allow_none_return
        is True and this expression is a call, allow it to return None.  This
        applies only to this expression and not any subexpressions.
        FTrb  N)&r  r  r  timeperf_counter_nsr  r  r  r   r?   rg  rq   visit_yield_from_exprrC   r>  r=   visit_await_exprrf  	Exceptionr"   r  rt  filer@  r  r  r  disallow_any_expris_stubr9  r  rj  r  disallowed_any_typer   r   r;  r  )r  r   r  r`  r  r  record_timet0old_is_calleer_  r  r*  s               r   rf  zExpressionChecker.accept  s    4&&&&t,,+ 	D4F 	%''B!%DK  ..."	  	(Zh%?%? 	(**44*HH" (z$'F'F (000NN" (z$'H'H (11$$1OO" (z$	'B'B (++DD+IIkk$'' 	 	 	!TX_)49dhotxGW       	 'D#&&& H.	4$	4 H$	4 ,,..		4
 S!!	4 H2	4 H((d333x++-- 	1O 	"9#899FFF 	'*495559M9O9ORT9TT555!&Ds   ,CD> >
F;FFr;  c                6    | j                             |          S )z}Return an instance type with type given by the name and no type
        arguments. Alias for TypeChecker.named_type.
        )r  r8  )r  r;  s     r   r8  zExpressionChecker.named_typeC  s     x""4(((r   c                    | j         j        j        dk    r|                     d          S |                     d          S )zFReturns a `typing.TypeAliasType` or `typing_extensions.TypeAliasType`.)r     ztyping.TypeAliasTypeztyping_extensions.TypeAliasType)r  r  r  r8  r"  s    r   rO  z&ExpressionChecker.type_alias_type_typeI  s;    8*g55??#9:::@AAAr   c           	         t          |          }t          |t          t          t          t
          f          p@t          || j                            dt          t          j
                  g                    S )z$Is a type valid as a *args argument?rI  )r   r   r   r   r   r   r}   r  r[  r   r5  r  s     r   r  z"ExpressionChecker.is_valid_var_argO  sd    c""#	7M:NOO 
S],,->I_A`A`@abbT
 T
 	
r   c           
     \   t          || j                            d|                     d          t	          t
          j                  g                    pWt          || j                            dt                      t                      g                    pt          |t                    S )z'Is a type valid as a **kwargs argument?r  r*  )
r}   r  r[  r8  r   r   r5  r   r   r   r  s     r   r  z*ExpressionChecker.is_valid_keyword_var_argV  s     ++6__^44gi>T6U6UV   . ++69J9JOL]L]8^  . #}--	
r   c                &    t          |          }t          |t                    rt          |j                  }t          |t                    rt          |          }t          |t                    r|j        }t          |t                    r|j	        
                              S t          |t                    r3|                                r|j        j	        
                              S t          |t                    rdS t          |t                    r0t           fd|                                D                       }|S t          |t"                    r|j        }t          |t                    rt          |j                  }t          |t                    rt          |          }t          |t                    r,|j	        j                              |j	        j                  S t          |t                    rdS dS dS )z*Does type have member with the given name?Tc              3  D   K   | ]}                     |          V  d S r   )r  )r   xr  r  s     r   r   z/ExpressionChecker.has_member.<locals>.<genexpr>~  s1      RRF33RRRRRRr   NF)r   r   r   r  r   r   r   r~  r   r   has_readable_memberr   r  r   r   r   r  r   r  metaclass_typer  )r  r_  r  r*  r  s   ` `  r   r  zExpressionChecker.has_memberi  s    c""c;'' 	3!#/22Cc9%% 	& %%Cc;'' 	,Cc8$$ 	88//777c<(( 	S__->-> 	<$88@@@W%% 	4Y'' 	RRRRRS=O=O=Q=QRRRRRFMX&& 	 8D$,, 9&t'788$	** ,%d++$)) Idi.F.Rty'?HHH$(( t55r   c                <    | j                             ||           dS )zCalled when we can't infer the type of a variable because it's not ready yet.

        Either defer type checking of the enclosing function to the next
        pass or report an error.
        N)r  r:  )r  r;  rI  s      r   not_ready_callbackz$ExpressionChecker.not_ready_callback  s"     	--dG<<<<<r   rp   c                   | j         j        d         }| j                             |d          }|j        ht	          t          |          t          t          f          s>| j                                         r%| j         	                    t          j        |           nD|                     |j        |          }| j                             |||t          j        dd           | j                             |d          S )Nr0  Factual typeexpected type)r  r  get_generator_yield_typer   r   r   r   r   r9  r  r   YIELD_VALUE_EXPECTEDrf  r(  INCOMPATIBLE_TYPES_IN_YIELDget_generator_receive_type)r  r$  return_typeexpected_item_typeactual_item_types        r   visit_yield_exprz"ExpressionChecker.visit_yield_expr  s    h+B/!X>>{ERR6>/ABBXwDWXXHH0022H .CQGGG#{{163EFFH"" " <   x22;FFFr   r=   c                   | j         d         }|| j                            d|g          }t          |                     |j        |                    }t          |t                    rt          t          j	        |          S | 
                    ||t          j                  }|sBt          t          |          t                    r | j        j                            d |           |S )Nr0  typing.Awaitabler	  )r  r  r[  r   rf  r   r   r   r   r  check_awaitable_exprr   INCOMPATIBLE_TYPES_IN_AWAITr   r  r  )r  r$  r`  expected_typery  r\  s         r   rF  z"ExpressionChecker.visit_await_expr  s    )"-$ H778J]O\\M%dkk!&-&H&HIIk7++ 	O95+NNNN'',H
 
 ! 	8Z0D0Dh%O%O 	8HL..tQ777
r   str | ErrorMessageignore_binderc                   | j                             ||                     d          ||dd          st          t          j                  S |                     d|g g |          d         }| j                             |d          }t          |          }|s:t          |t                    r%|j        s| j         j                                         |S )zyCheck the argument to `await` and extract the type of value.

        Also used by `async for` and `async with`.
        rg  r\  r]  	__await__r   F)r  r(  r8  r   r   r5  rl  get_generator_return_typer   r   r   r  r  r  )r  r   r2  r  rl  r
  r?  s          r   rh  z&ExpressionChecker.check_awaitable_expr  s     x%%t122Cm_
 
 	 9122266{Ar2sSSTUVIx99)UKKH&x00H!.x99. !*.
 ++---Or   rq   c                   | j         j        d         }t          |                     |j                            }t          |t                    rt          t          j        |          }n;| j         	                    |          rt          |          r/t          |          s | j         j                            ||           t          t          j                  }| j                             d|||g          }|                    |           |                     d|g g |          \  }}nyt          |          rt          |          s:| j         j                            ||           t          t          j                  }n!|                     ||t(          j                  }| j                             |d          }	| j                             |d          }
| j                             |
|	|t(          j        dd           t          |          }| j                             |d	          }|sBt          t          |          t2                    r | j         j                            d |           |S )
Nr0  r	  r  __iter__r(  Fr\  r]  )is_coroutine)r  r  r   rf  r   r   r   r   r  rO  is_async_defhas_coroutine_decoratorr  yield_from_invalid_operand_typer5  r[  r  rl  r<  rh  r    INCOMPATIBLE_TYPES_IN_YIELD_FROMr^  r(  ro  r   r  )r  r$  r`  rb  subexpr_type	iter_typer  generic_generator_typer  rc  rd  	expr_types               r   rE  z'ExpressionChecker.visit_yield_from_expr  s^    h+B/
 't{{16':':;; lG,, 	%i&@\ZZZIIX&&|44 	L)) N2I+2V2V N<<\1MMMy566H%)X%@%@"Xx$B& &" #++A...99L"b:P :  LIqq !.. 3J;3W3W <<\1MMM#I$899		 55 !%5%V 	 "X>>{ERR8<<YNN=	
 	
 	
 $I..	H66yu6UU	  	8Z	0J0JH%U%U 	8HL..tQ777r   rf   c                    |j         S r   r   r1  s     r   visit_temp_nodez!ExpressionChecker.visit_temp_node  	    vr   rl   c                   t          |j                  t          t                    rj        t
          j        k    srt          |j                  s| j	        
                    d|           |j        r;t          fd|j        D                       s| j	        
                    d|           t          t
          j                  S )Nz3TypeVar default must be a subtype of the bound typec              3  $   K   | ]
}|k    V  d S r   r   )r   r  	p_defaults     r   r   z8ExpressionChecker.visit_type_var_expr.<locals>.<genexpr>  s(      #M#M5I$6#M#M#M#M#M#Mr   z3TypeVar default must be one of the constraint types)r   r  r   r   type_of_anyr   r  r}   r  r  r  r  r  r5  )r  r$  r  s     @r   visit_type_var_exprz%ExpressionChecker.visit_type_var_expr  s    #AI..	y'**	X%)HHHi77 XSUVWWWx X#M#M#M#MAH#M#M#M M M XSUVWWWy-...r   rZ   c                4    t          t          j                  S r   r   r   r5  r1  s     r   visit_paramspec_exprz&ExpressionChecker.visit_paramspec_expr      y-...r   rm   c                4    t          t          j                  S r   r  r1  s     r   visit_type_var_tuple_exprz+ExpressionChecker.visit_type_var_tuple_expr   r  r   rW   c                4    t          t          j                  S r   r  r1  s     r   visit_newtype_exprz$ExpressionChecker.visit_newtype_expr#  r  r   rU   c                "   |j         j        }|ri| j        j        j        r+t          |          r| j                            d||           t          || j        j        | j        j	        | j        |           t          t          j                  S )NzNamedTuple typer(  )r  
tuple_typer  r  r.  r   r  r/  r   r0  r   r   r5  )r  r$  r  s      r   visit_namedtuple_exprz'ExpressionChecker.visit_namedtuple_expr&  s    V&
 	x7 W<X= = W 445F
TUVVV"DH,dh.G[\    y-...r   rI   c                Z   t          |j        |j                  D ]x\  }}|q|                     |          }t	          t          |          t                    s:|j        j        |         j	        }t	          |t                    r||_        d|_        yt          t          j                  S NT)r  r   r  rf  r   r   r   r  rW  r   ro   r   r  r   r5  )r  r$  r;  r  r_  rE  s         r   visit_enum_call_exprz&ExpressionChecker.visit_enum_call_expr2  s    qw11 	/ 	/KD% kk%((!/#"6"6@@ /&,t,1C!#s++ /
 $'*.y-...r   rj   c                4    t          t          j                  S r   r  r1  s     r   visit_typeddict_exprz&ExpressionChecker.visit_typeddict_exprA  r  r   r\   c                    |j         S r   r|  r1  s     r   visit__promote_exprz%ExpressionChecker.visit__promote_exprD  r~  r   rb   c                6    |                      |j                  S r   )rf  r   r1  s     r   visit_star_exprz!ExpressionChecker.visit_star_exprG  s    {{16"""r   c                ,    |                      d          S )zReturn instance type 'object'.rU  r9  r"  s    r   rH  zExpressionChecker.object_typeK  s    0111r   c                ,    |                      d          S )zReturn instance type 'bool'.rN  r9  r"  s    r   rk  zExpressionChecker.bool_typeO  s    ///r   
known_typec                    d S r   r   )r  r   r  s      r   r(  z)ExpressionChecker.narrow_type_from_binderS  s    SVSVr   r  c                    d S r   r   )r  r   r  r  s       r   r(  z)ExpressionChecker.narrow_type_from_binderV  s	     cr   c                l   t          |          t          k    r| j        j                            |          }|rzt          t          |          t                    r| j        j        sL|rt          ||d          sdS t          ||          }t          t          |          t                    r|S |S |S )zNarrow down a known type of expression using information in conditional type binder.

        If 'skip_non_overlapping' is True, return None if the type and restriction are
        non-overlapping.
        T)prohibit_none_typevar_overlapN)r*   r7   r  r  r  r   r   r   rj  r,   r-   r   )r  r   r  r  restrictionr+  s         r   r(  z)ExpressionChecker.narrow_type_from_binder[  s     4==L(((/--d33K   ?:66@@ EIXEc  (  0D41 1 1    4/
KHHoh77II ' '&r   c                     t          |t                    rHt          |t                    r3t           fdt          |j        |j                  D                       S                      ||          S )Nc              3  ~   K   | ]7\  }}                     t          |          t          |                    V  8d S r   )has_abstract_typer   )r   callerr  r  s      r   r   z;ExpressionChecker.has_abstract_type_part.<locals>.<genexpr>|  s\        "FF &&v'>'>PV@W@WXX     r   )r   r   r  r  r   r  r  r  r  s   `  r   r  z(ExpressionChecker.has_abstract_type_party  s    k9-- 	*[)2T2T 	    &)+*;[=N&O&O      %%k;???r   c                t   t          |t                    ot          |t                    o|                                oz|                                j        p|                                j        oHt          |j        t                    o.|j        j	        j        p|j        j	        j        o| j
        j         S r   )r   r   r   r  r  r  r  r  r   r   r  allow_abstract_callr  s      r   r  z#ExpressionChecker.has_abstract_type  s    {L11 1;111''))1 ((**6_+:Q:Q:S:S:_1 ;+X66	1
 !&2Wk6F6K6W1 H00	
r   )
r  r  r  r/   r  rw   r  r  r   r  r   r  )r$  rV   r   r   F)r$  r]   r-  r   r   r   )rE  ro   rI  rD   r   r   )r   rT   r   r   )r$  r?   r`  r   r   r   )rh  rJ   r   r   )r$  r?   r   r  )rH  r   r  r  r   r  r   rJ   r   r   )r  r  r   r   )r  r   r  r  r  r  ru  r  rI  rD   r  r  r   r   )r  r  r  r   r   r  )
r  rJ   r  r   r*  r  r  r   r   r   r_  r   r   r   )r  r   r  r  rI  rD   r   r   )
r  r   r  r  rI  rD   r  r  r   r   )r  rk   r   r   )r  r   r   r   )r  r   r  r  rI  rD   r  r  r  r   r   r   )r   rS   r   rH  )ra  r]   r   rb  )r$  r?   re  r  rE  ro   r   rf  )r  r   r  r  r  rm  r  rn  r}  ro  ru  r  r   r  rH  r  rI  rD   r   r   )r  r   ru  r  r  r  r  rn  r  r  r   r   )r  r   ru  r  r  r  rI  rD   r  rn  r  r  r   r   )r  r   ru  r  r  r  rI  rD   r  rn  rH  r   r  r  r   r   r  )r  r  r  r   ru  r  r  r  rI  rD   r  rn  rH  r  r   r   )r  r   ru  r  r   r  )r  r   r  r   r2  rD   r   r  r   )r  r   r$  r?   r  r  rH  r  r  r  r   r   )r$  r?   rH  r   r  r  r   r   )NNNNN)r  r   ru  r  r  r  rI  rD   r  rn  r  r  r  r  rH  r  r  r  r   r  )r  r   ru  r  r  r  rI  rD   r  rn  r  r  r  r  rH  r  r   r  )r   rk   r  r  r   r   )r  r   rI  rD   r   r   )ru  r  r   rm  )r  r   r   r   )
r  r   ru  r  r  r  r}  ro  r   rm  )r  r   r  rD   r   r   )r  r   ru  r  r  r  r  rn  r}  ro  r  r   rI  rD   r   r   )r  r   ru  r  r  r  r  rn  r}  ro  rC  rD  r  r   rI  rD   r   rE  )r   r'   )r  r   ru  r  r  rm  r}  ro  rJ  rK  r   rL  )r  r   r  rD  rI  rD   r   r   )r  r   rV  rm  rW  r  rX  rn  r}  ro  rI  rY  rH  r  r  r  r   r   )r  r   rV  rm  rW  r  rX  rn  rj  r  rI  rD   r   rq  )rH  r   r  r  rI  rD   r   r  )r  rm  r  r  ru  r  r  r   r}  ro  rI  rD   r  r  rH  r  r   r  )r  r   r  r   r  r:   r  r   r^  rK  r  rK  r  r   rH  r  rI  rD   r  rD   r   r  )r  r   ru  r  r  r  r  rn  r  r  rH  r  rI  rD   r   r  )
r  rm  r  r  r  rn  r   r   r   r  )r  r  ru  r  r  rm  r  r  r  rn  r  r  rH  r  rI  rD   r   r  )r  r  r  rm  r  r  r  rn  ru  r  rI  rD   r   r  )r  rm  r  r  r   r   r0  )r  r  ru  r  r  rm  r  r  r  rn  r  r  rH  r  r  r   rI  rD   r  rK  r   r  r  )r  r  r  r  r   r  )r   r  r   r  )r  rm  r  r  r  rn  ru  r  r  r   rI  rD   r   r   )
r  r   r   rD  rI  rD   r"  r   r   r   )ru  r  r  r   r   r  )r  r   ru  r  r  r  r  rn  rI  rD   r   r  )r$  rS   r  r   r   r   )r$  rS   r  r   r4  r  r   r   )r  r  r$  r   rI  rD   r   r   )r   r   )r  r   r(  r  r   r   )r*  r   r+  r   r   r   )r$  rO   r   r   )r$  rc   r   r   )r$  r>   r   r   )r$  rK   r   r   )r$  rB   r   r   )r$  rH   r   r   )r$  rX   r   r   )r$  rA   r   r   )r   rJ   r   r  )r*  r   r+  r   rc  r  r  r  rd  r   r   r   )r\  r  r$  r   ru  r  r  r  rI  rD   r  r  r   r  )r\  r  r$  r   ru  r  r  r  rI  rD   r  r  r   r  )r  r  r$  r   rT  r   ru  r  r  r  rI  rD   r   r  )r  r  rV  r   r  rJ   rw  r   r  rJ   rI  rD   r   r  )r\  r  r$  r   r  rJ   rI  rD   rH  r   r   r  )r$  rX   rI  rD   r   r   )r$  r<   r   r   )r$  rn   r   r   )r$  rN   r   r   )rV  r   r$  rN   r  r  r   r   )r*  r   r   rK  )r*  r   r^  rK  r   r  )rV  r   r  ra   r   r   )rX  rJ   r   r  )rV  r   rX  rJ   r   r   )rV  r   r   r   )r  r   rX  rJ   r  r   r   r  )r&  rk   rX  rJ   rI  rD   r   r   )r   r@   r   r   )r   r;   r   r   )r   r^   r   r   )r   r^   r   r  )rL  ri   r   r   )rS  rh   r   r   )rS  r   r2  rD   r3  r   r   r   )r   r   ru  r  r2  rD   r   rm  )r  r   ru  r  r2  rD   r   r   )r$  rR   r   r   )r$  r`   r   r   )r$  r~  r  r  r   r  )r$  r~  r   r  r  r  r   r   )r   rg   r2  r   r   r   )r$  rg   r   r   )r$  rF   r   r  )r$  rF   r  r   r   r   )r$  rF   r   r   )rI  r  r  rF   r   r  )r$  rP   r   r   )r$  rP   r   r  )r$  rd   r   r   )r$  rd   r   r  )r$  ra   r   r   )r$  rQ   r   r   )r$  r_   r   r   )r$  rM   r   r   )
r  rM   r  r  r  r  r  r  r   r   )r$  rG   r   r   )r$  r$  r   r  )r$  rC   r`  r   r   r   )FT)r  r?  r   rJ   rI  r  r`  r   r@  r   r   r   )NFFF)r   rJ   r  r  r`  r   r  r   r  r   r   r   )r;  r  r   r   )r   r   )r_  r   r  r  r   r   )r;  r  rI  rD   r   r  )r$  rp   r   r   )r$  r=   r`  r   r   r   )
r   r   r2  rD   r  rk  rl  r   r   r   )r$  rq   r`  r   r   r   )r$  rf   r   r   )r$  rl   r   r   )r$  rZ   r   r   )r$  rm   r   r   )r$  rW   r   r   )r$  rU   r   r   )r$  rI   r   r   )r$  rj   r   r   )r$  r\   r   r   )r$  rb   r   r   )r   rJ   r  r   r   r   )r   rJ   r  r   r  r   r   r  )r  r   r  r   r   r   )r   r   r   r   __annotations__r   r#  r,  r'  r6  rD  rg  rk  re  r  r  r  r  r  r  r  r  r  r  r  r  r>  r&  r  rM  rP  rS  r  rU  rV  r  r  r  r  r  r  r  r  r  r  r=  r  r  r  r  r  r  r(   r7  r6  r5  r<  r  r_  rc  r  r  r  r  r  r  r  r  r  r   r  r  r  r$  r  r  r  r  r&  rO  rQ  r-  r2  r5  r7  r:  r<  r>  r]  r  rj  rs  rl  r  r  r  rR  rJ  rK  r  r  r  r  r  r  r  r  r  r  r  r  r  r3  r7  rB  r=  rR  rU  rF  rj  rP  r{  r}  r  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r#  r  r>  r  rf  r8  rO  r  r  r  rZ  re  rF  rh  rE  r}  r  r  r  r  r  r  r  r  r  rH  rk  r   r(  r  r  r   r   r   r  r  ,  s]          "!!!#### 0///****NNN O  O  O  OD       	 	 	 	C C C C CJ3 3 3 3$   2	R 	R 	R 	R 	R
 
 
 
S S S S SjG G G G.   8   ,   ,	M 	M 	M 	M_ _ _ _(- (- (- (-T0+ 0+ 0+ 0+d6 6 6 6pR R R R   1 1 1 1(
 
 
 
0

 

 

 

] ] ] ]~   0 #	*1 1I    
 #_$56"_$56$,.?#@!NO#DE	A AN    %P %P %P %PN	" 	" 	" 	") ) ) )VG G G GR% % % %@
 
 
 
$
 
 
 
> 26#'' ' ' ' 'R   &= = = =H "9 9 9 9 9v* * * *D 26+/$(#'%)tY tY tY tY tYly' y' y' y'v   0,- ,- ,- ,-\        #% #% #% #%JN
 N
 N
 N
`IR IR IR IRV6* 6* 6* 6*p
 
 
 

- - - -^Q Q Q Q8 $($(N N N N N`;+ ;+ ;+ ;+z   , (,#'K K K K KZ&_ &_ &_ &_PD D D DL9& 9& 9& 9&vR6 R6 R6 R6h   *$ $ $ $b d d d d dLL L L L . . . ^.P
 P
 P
 P
d3 3 3 3t "'
 
 
 
 
 	T 	T 	T 	TL L L L      KO( ( ( ( (T
 
 
 
&; ; ; ;   6
 
 
 
E E E EE E E EG G G G1 1 1 13 3 3 34 4 4 4k; k; k; k;ZS S S Sj   * +/48#{N {N {N {N {N {NH &*"` "` "` "` "`V &*K K K K K8
 
 
 
<A A A AR $m m m m m^IM IM IM IMV    	 	 	 	       8 8 8 8 QUJ J J J JX! ! ! !.
 .
 .
 .
`, , , ,@$ $ $ $L   , , , ,( JO#B #B #B #B #BJ' ' ' '   .   4   >D D D D.)/ )/ )/ )/V` ` ` ` KPC: C: C: C: C: C:J6W 6W 6W 6WpJ/ J/ J/ J/XA A A A? ? ? ?       D!6 !6 !6 !6FY Y Y Yg g g gR- - - -^	1 	1 	1 	1PU PU PU PUd   &"I "I "I "IHKO KO KO KOZQ$ Q$ Q$ Q$fP( P( P( P(dH H H H 
 
 
 


 
 
 


 
 
 
2 .2 Z  Z  Z  Z  ZD" " " "H#W #W #W #WJO O O O Ol #(,0` ` ` ` `4 %)"'!&= = = = =~) ) ) )B B B B
 
 
 

 
 
 
&% % % %N= = = =G G G G*     UZ    .: : : : :x   
/ 
/ 
/ 
// / / // / / // / / /
/ 
/ 
/ 
// / / // / / /   # # # #2 2 2 20 0 0 0 VVV XV   X
 PU    <@ @ @ @	
 	
 	
 	
 	
 	
r   r  Fignore_in_type_objc                F    |                      t          |                    S )zWhether t contains an Any type)rf  
HasAnyType)r   r  s     r   r  r    s    88J122333r   c                  L     e Zd Zd fdZddZd fd
ZddZddZddZ xZ	S )r  r  r   r   r  c                l    t                                          t          j                   || _        d S r   )superr   r   ANY_STRATEGYr  )r  r  	__class__s     r   r   zHasAnyType.__init__  s,    +,,,"4r   r   r   c                ,    |j         t          j        k    S r   )r  r   r5  r  r   s     r   	visit_anyzHasAnyType.visit_any  s    }	 666r   r   c                    | j         r|                                rdS t                                          |          S )NF)r  r  r  visit_callable_type)r  r   r  s     r   r  zHasAnyType.visit_callable_type  s:    " 	q}} 	5ww**1---r   r   c                    |                                 r|j        gng }|                     |j        g||j        z             S r   )rn  r  query_typesr  r  r  r   r  s      r   visit_type_varzHasAnyType.visit_type_var  sA    !"819++b 9 9AH DEEEr   r   c                x    |                                 r|j        gng }|                     |j        g|          S r   rn  r  r  r  r  s      r   visit_param_speczHasAnyType.visit_param_spec  :    !"819++b 9 9:::r   r   c                x    |                                 r|j        gng }|                     |j        g|          S r   r  r  s      r   visit_type_var_tuplezHasAnyType.visit_type_var_tuple  r  r   )r  r   r   r  )r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )
r   r   r   r   r  r  r  r  r  __classcell__r  s   @r   r  r    s        5 5 5 5 5 57 7 7 7. . . . . .
F F F F; ; ; ;; ; ; ; ; ; ; ;r   r  c                j    t          |           } t          | t                    o| j        j        dk    S )z;Whether t came from a function decorated with `@coroutine`.typing.AwaitableGenerator)r   r   r   r   r   r   s    r   rt  rt    s.    Aa""Uqv:U'UUr   c                   t          |           } t          | t                    rB| j        j        dk    r2t          | j                  dk    rt          | j        d                   } t          | t                    o| j        j        dk    S )z9Whether t came from a function defined using `async def`.r     r  ztyping.Coroutine)r   r   r   r   r   r  ru  r   s    r   rs  rs    sx     	A1h'FO:::KK1AF1I&&a""Lqv:L'LLr   c                r    t          |           } t          | t                    ot          | j                  S r   )r   r   r   r   r   r   s    r   rs  rs    s,    Aa##5QW5r   mappingrL  rV  rm  rW  r  c                    t          |           dk    oht          |           dk    o7| d                  t          j        k    o| d                  t          j        k     ot	          fd| D                        S )Nr   r  r   c              3     K   | ]C}|         t           j        k    o(t          t          |                   t                     V  Dd S r   )r   r4   r   r   r   )r   r  rW  rV  s     r   r   z'is_duplicate_mapping.<locals>.<genexpr>  sf       
 
  Ou. P|A??OOO
 
 
 
 
 
r   )r  r   r3   r4   r   )r  rV  rW  s    ``r   re  re    s     	Gq 	
 LLA <WQZ(EN:<WQZ(EO;
	
  
 
 
 
 
 
 
 
 
 
 
r   r  r   r  c                .    |                      |          S )z>Return a copy of a callable type with a different return type.r  r  )r  r  s     r   r  r    s    ??L?111r   c                  ,     e Zd ZdZd	 fdZd
dZ xZS )rN  zQuery whether an argument type should be inferred in the second pass.

    The result is True if the type has a type variable in a callable return
    type anywhere. For example, the result for Callable[[], T] is True if t is
    a type variable.
    r   r  c                ^    t                                          t          j                   d S r   r  r   r   r  r  r  s    r   r   z ArgInferSecondPassQuery.__init__  $    +,,,,,r   r   r   r   c                T    |                      |j                  pt          |          S r   )r  r  r   r  s     r   r  z+ArgInferSecondPassQuery.visit_callable_type  s%    ,,@a0@0@@r   r  r  )r   r   r   r   r   r  r  r  s   @r   rN  rN    sc         - - - - - -A A A A A A A Ar   rN  r  c                L    | d uo |                      t                                S r   )rf  HasErasedComponentsQueryr   s    r   r  r    s$    D=AQXX&>&@&@AAAr   c                  ,     e Zd ZdZd	 fdZd
dZ xZS )r  z<Visitor for querying whether a type has an erased component.r   r  c                ^    t                                          t          j                   d S r   r  r  s    r   r   z!HasErasedComponentsQuery.__init__  r  r   r   r   r   c                    dS r  r   r  s     r   visit_erased_typez*HasErasedComponentsQuery.visit_erased_type      tr   r  )r   r   r   r   )r   r   r   r   r   r  r  r  s   @r   r  r    sW        FF- - - - - -       r   r  c                L    | d uo |                      t                                S r   )rf  HasUninhabitedComponentsQueryr   s    r   r#  r#    s$    D=FQXX&C&E&EFFFr   c                  ,     e Zd ZdZd	 fdZd
dZ xZS )r  zEVisitor for querying whether a type has an UninhabitedType component.r   r  c                ^    t                                          t          j                   d S r   r  r  s    r   r   z&HasUninhabitedComponentsQuery.__init__  r  r   r   r   r   c                    dS r  r   r  s     r   visit_uninhabited_typez4HasUninhabitedComponentsQuery.visit_uninhabited_type  r  r   r  )r   r   r   r   )r   r   r   r   r   r  r  r  s   @r   r  r    sW        OO- - - - - -       r   r  r  r  c                    t                      t                    t           t                    rt                      t          t                    rt                    d
d}t          t                    r$t           t          t
          t          f          rdS  |           r |          rdS t           t                    r-t          fd 	                                D                       S t          t                    r-t           fd	                                D                       S t           t                    r,t          t                    rdS t           j                  S t          t                    rt           t                    r j         t           t
                    r j        d	         j         t           t                    rt!                      t           t                    rj         j        j        v rdS t'          t)          j                   t)          j                            S )a  Return if caller argument (actual) is roughly compatible with signature arg (formal).

    This function is deliberately loose and will report two types are similar
    as long as their "shapes" are plausibly the same.

    This is useful when we're doing error reporting: for example, if we're trying
    to select an overload alternative and there's no exact match, we can use
    this function to help us identify which alternative the user might have
    *meant* to match.
    r_  r   r   r   c                    t          | t                    pMt          | t                    o|                                 p$t          | t                    o| j        j        dk    S )Nr  )r   r   r   r  r   r   r   r  s    r   is_typetype_likez4arg_approximate_similarity.<locals>.is_typetype_like/  sX    sH%% T3--C#//2C2CT3))Rch.??.R	
r   Tc              3  8   K   | ]}t          |          V  d S r   r  )r   r  r  s     r   r   z-arg_approximate_similarity.<locals>.<genexpr>>  s.      ``-dF;;``````r   c              3  8   K   | ]}t          |          V  d S r   r  )r   r  r  s     r   r   z-arg_approximate_similarity.<locals>.<genexpr>@  s.      ``-fd;;``````r   r   r  )r   r   r   r   r   r   r   r   r  r  r   r  r~  r   r   r   r   r   r  r}   r   r   )r  r  r  s   `` r   r  r    sP    V$$FV$$F &+&& 1(00&+&& 1(00
 
 
 
 &,'' f|ZBCC 	4 $4$4V$<$< t &)$$ a````H]H]H_H_``````&)$$ a````H]H]H_H_`````` &-(( Cfm,, 	4)&/6BBB &(## 	fl++ 	%_Ffj)) 	.\!_-Ffi(( 	,#F++Ffh'' 	FK6;?,J,J4 i*622I4H4P4PQQQr   r   r  r  r  r  r  rn  c                   t          |          rdS fd| D             }t                    D ]\  }t          |d          rfdt          |          D             }g }g }	|D ]L\  }
}| |
         }|                    |j                   |D ]"}|	                    |j        |                    #Mt          |	          st          |          s dS dS )a  May an argument containing 'Any' cause ambiguous result type on call to overloaded function?

    Note that this sometimes returns True even if there is no ambiguity, since a correct
    implementation would be complex (and the call would be imprecisely typed due to Any
    types anyway).

    Args:
        items: Overload items matching the actual arguments
        arg_types: Actual argument types
        arg_kinds: Actual argument kinds
        arg_names: Actual argument names
    Fc           
     P    g | ]"}t          |j        |j        fd           #S )c                    |          S r   r   r  s    r   rw  z:any_causes_overload_ambiguity.<locals>.<listcomp>.<lambda>q  s    IVWL r   )r   r  r  )r   r  r  r  r  s     r   r{  z1any_causes_overload_ambiguity.<locals>.<listcomp>o  sN         	y$.$.BXBXBXBX	
 	
  r   T)r  c                :    g | ]\  }}|         ||         fS r   r   )r   item_idxlookuparg_idxs      r   r{  z1any_causes_overload_ambiguity.<locals>.<listcomp>{  s@     + + +$Hf'?+6'?++ + +r   )r  rz  r  r  r?  r  )r   r  r  r  r  actual_to_formalrk  matching_formals_unfilteredmatching_returnsmatching_formalsr  formalsmatched_callabler  r  s     ```         @r   r  r  Y  sf   & l## u      	   'y11   T::: 	+ + + +(12B(C(C+ + +'  "!%@ 	P 	P!'#(?  ''(8(ABBB & P PF$++,<,Fv,NOOOOP!"233 NK[<\<\ tt5r   r   c                R      sdS t           fd dd          D                       S )NTc              3  D   K   | ]}t          |d                    V  dS )r   N)r|   )r   r   r   s     r   r   z!all_same_types.<locals>.<genexpr>  s1      <<Q|AuQx((<<<<<<r   r   )r   )r   s   `r   r  r    s;     t<<<<%)<<<<<<r   r  Sequence[CallableType],tuple[list[CallableType], list[TypeVarType]]c                   g }i }g }| D ]}|                                 rt          |          }i }|j        D ]k}|j        }||vrNt	          |t
          t          f          r*t	          |t                    sJ |||<   |                    |           ||         ||j	        <   lt          ||          }|                    |           ||fS )a<  Takes all the typevars present in the callables and 'combines' the ones with the same name.

    For example, suppose we have two callables with signatures "f(x: T, y: S) -> T" and
    "f(x: List[Tuple[T, S]]) -> Tuple[T, S]". Both callables use typevars named "T" and
    "S", but we treat them as distinct, unrelated typevars. (E.g. they could both have
    distinct ids.)

    If we pass in both callables into this function, it returns a list containing two
    new callables that are identical in signature, but use the same underlying TypeVarType
    for T and S.

    This is useful if we want to take the output lists and "merge" them into one callable
    in some way -- for example, when unioning together overloads.

    Returns both the new list of callables and a list of all distinct TypeVarType objects used.
    )r  r&   r  r   r   r   r   r   r  r  r#   )r  r   unique_typevarsr  rj  renamerd  r;  s           r   r  r    s    & "$F.0O#%I   	1/77FF& 	6 	6{..!"}6F&GHH ! %b+66666,.OD)$$R((( / 5ru 00Ff9r   r_  r   c                j    t          |           } t          | t                    r| j        | j        S | S )z>If possible, get a more precise literal type for a given type.)r   r   r   rP  r  s    r   r  r    s7    
#

C#x   $S%9%E##Jr   r   rJ   c                4   t          | t                    r*| j        }t          |t                    o|j        t
          v S t          | t                    rC| j        }t          |t                    o&t          t          |j
                  t                    S dS )z-Returns 'true' if the given node is a LiteralF)r   rN   rh  r]   r   r   rV   r   r   r   rj  r   )r   rh  
underlyings      r   r  r    s    $	"" Qy$((PT]>P-PP$!! 
Y
*i00 
ZJ-..6
 6
 	
 5r   c                    t          |           } ddh}t          | t                    rt          d | j        D                       S t          | t
                    r| j        j        |v rdS dS )z?Is this one of builtin byte types, or a union that contains it?r   r   c              3  4   K   | ]}t          |          V  d S r   )r  r  s     r   r   z&has_bytes_component.<locals>.<genexpr>  s+      ==a&q))======r   TF)r   r   r   r  r   r   r   r   )r_  
byte_typess     r   r  r    sv    
#

C"$89J#y!! >==39======#x   SX%6*%D%Dt5r   TypeInfo | Nonec                   t          |           } t          | t                    r(|                                 r|                                 S t          | t
                    r| j        } t          | t                    rt          | j                  } t          | t                    rt          |           } t          | t                    r| j        S dS )zXGets the TypeInfo for a type, indirecting through things like type variables and tuples.N)r   r   r   r  r  r   r  r   r  r   r   r   r   r  s    r   r  r    s    
#

C#|$$ !):): !   #x   h#{## /co..#y!! "S!!#x   x 4r   r   r  c                    | sdS |                      d          d         }|t          j                                        v p?|t          j                                        v p|t          j                                        v S )NFr   r0  )splitr   rQ  r  rS  r  )r   
short_names     r   r  r    sy     u$$R(Ji*11333 	=5<<>>>	=3::<<<r   PartialType | Nonec                F    | t          | t                    r| j        d S | S r   )r   r   r   r   s    r   rY  rY    s%    y
1k22yafntHr   rI  c                    t          |           } t          | t                    rdS t          | t                    rt	          d | j        D                       S dS )NTc              3  4   K   | ]}t          |          V  d S r   )rB  )r   r  s     r   r   z'is_type_type_context.<locals>.<genexpr>  s+      HH$'--HHHHHHr   F)r   r   r   r   r  r   r(  s    r   rB  rB  
  s]    g&&G'8$$ t'9%% IHH'-HHHHHH5r   )r   r   r   r   )r   r]   r   r   r  )r   r   r  r   r   r   )r  rL  rV  rm  rW  r  r   r   )r  r   r  r   r   r   )r   r  r   r   )r  r   r  r   r   r   )r   r  r  rm  r  rm  r  r  r  rn  r   r   )r   rm  r   r   )r  r  r   r  )r_  r   r   r   r  r  )r_  r   r   r  )r   r  r   r   )r   r  r   r  )rI  r  r   r   (  r   
__future__r   enumr  rC  collectionsr   collections.abcr   r   r   
contextlibr   rF  r	   r
   r   r   r   r   rG  r   r   r   mypy.checkerr  mypy.errorcodes
errorcodesr  r   r   r   r   r   r   r   mypy.argmapr   r   r   mypy.checker_sharedr   mypy.checkmemberr   mypy.checkstrformatr   mypy.erasetyper   r   r    mypy.errorsr!   r"   mypy.expandtyper#   r$   r%   r&   
mypy.inferr'   r(   r)   mypy.literalsr*   mypy.maptyper+   	mypy.meetr,   r-   mypy.message_registryr.   mypy.messagesr/   r0   
mypy.nodesr1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   mypy.optionsrr   mypy.pluginrs   rt   ru   rv   rw   mypy.semanal_enumrx   
mypy.statery   mypy.subtypesrz   r{   r|   r}   r~   mypy.traverserr   mypy.typeanalr   r   r   r   r   r   r   mypy.typeopsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
mypy.typesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   mypy.types_utilsr   r   r   r   mypy.typestater   mypy.typevarsr   	mypy.utilr   mypy.visitorr   rK  r   r  r   r   r   rG  r   r   r   r   uniqueEnumr  r  r  r  r  r  r	  r  r  BoolTypeQueryr  rt  rs  rs  re  r  rN  r  r  r#  r  r  r  r  r  r  r  r  r  r  rY  rB  r   r   r   <module>r2     s   M M M " " " " " "       # # # # # # 8 8 8 8 8 8 8 8 8 8 % % % % % % F F F F F F F F F F F F F F F F C C C C C C C C           V V V V V V V V V V V V V V V V V V W W W W W W W W W W : : : : : : 2 2 2 2 2 2 6 6 6 6 6 6 [ [ [ [ [ [ [ [ [ [ ; ; ; ; ; ; ; ;            a ` ` ` ` ` ` ` ` ` ! ! ! ! ! ! 2 2 2 2 2 2 @ @ @ @ @ @ @ @ . . . . . . 5 5 5 5 5 5 5 5C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C CH - , , , , ,              ) ( ( ( ( (                    0 / / / / /                                                        () ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )T            & % % % % % ' ' ' ' ' ' ( ( ( ( ( ( * * * * * * "	4$S,QXY[__
     
    
	& 	& 	&  	 	 	 	& & &         I         @O O O O Oy O O O         (/  / / / /&-  - - - -%+  + + + +_]
 _]
 _]
 _]
 _]
)$/1K _]
 _]
 _]
D{4 4 4 4 4
; ; ; ; ;$ ; ; ;4V V V VM M M M06 6 6 6
   22 2 2 2
A A A A Ae1 A A A B B B B    u2   G G G G    E$7   <R <R <R <R~7 7 7 7t= = = =* * * *Z   
 
 
 
      &           r   