
    yIfO              
      &   U d dl mZ d dlmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZmZmZmZmZ d dlmZ d dlmZmZ erd d	lmZ  G d
 de          Zi d edd          d edd          d edd          d edd          d edd          d edd          d edd          d edd          d edd          d  ed!d          d" ed#d          d$ ed%d          d& ed'd          d( ed)d          d* ed+d          d, ed-d          d. ed/d          i d0 ed1d          d2 ed3d          d4 ed5d          d6 ed7d          d8 ed9d          d: ed;d          d< ed=d          d> ed?d          d@ edAd          dB edCd          dD edEd          dF edGd          dH edId          dJ edKd          dL edMd          dN edOd          dP edQd           edRd           edSd           edTd           edUd           edVd           edWd          dXZdYedZ<    ed[ eD                       Zd\Z G d] d^e          Z G d_ d`e	          ZdfdeZdS )g    )annotations)TYPE_CHECKING
NamedTupleN)nodes)BaseChecker)in_type_checking_block"is_node_in_type_annotation_contextis_postponed_evaluation_enabledonly_required_for_messages
safe_infer)TYPING_NORETURN)HIGH	INFERENCE)PyLinterc                  $    e Zd ZU ded<   ded<   dS )TypingAliasstrnameboolname_collisionN)__name__
__module____qualname____annotations__     L/var/www/piapp/venv/lib/python3.11/site-packages/pylint/extensions/typing.pyr   r      s'         IIIr   r   ztyping.TupletupleFztyping.Listlistztyping.Dictdictz
typing.Setsetztyping.FrozenSet	frozensetztyping.Typetypeztyping.Dequezcollections.dequeTztyping.DefaultDictzcollections.defaultdictztyping.OrderedDictzcollections.OrderedDictztyping.Counterzcollections.Counterztyping.ChainMapzcollections.ChainMapztyping.Awaitablezcollections.abc.Awaitableztyping.Coroutinezcollections.abc.Coroutineztyping.AsyncIterablezcollections.abc.AsyncIterableztyping.AsyncIteratorzcollections.abc.AsyncIteratorztyping.AsyncGeneratorzcollections.abc.AsyncGeneratorztyping.Iterablezcollections.abc.Iterableztyping.Iteratorzcollections.abc.Iteratorztyping.Generatorzcollections.abc.Generatorztyping.Reversiblezcollections.abc.Reversibleztyping.Containerzcollections.abc.Containerztyping.Collectionzcollections.abc.Collectiontyping.Callablezcollections.abc.Callableztyping.AbstractSetzcollections.abc.Setztyping.MutableSetzcollections.abc.MutableSetztyping.Mappingzcollections.abc.Mappingztyping.MutableMappingzcollections.abc.MutableMappingztyping.Sequencezcollections.abc.Sequenceztyping.MutableSequencezcollections.abc.MutableSequenceztyping.ByteStringzcollections.abc.ByteStringztyping.MappingViewzcollections.abc.MappingViewztyping.KeysViewzcollections.abc.KeysViewztyping.ItemsViewzcollections.abc.ItemsViewztyping.ValuesViewzcollections.abc.ValuesViewz!contextlib.AbstractContextManagerz&contextlib.AbstractAsyncContextManagerz
re.Patternzre.Matchzcollections.abc.Hashablezcollections.abc.Sized)ztyping.ContextManagerztyping.AsyncContextManagerztyping.Patternztyping.Matchztyping.Hashableztyping.Sizedzdict[str, TypingAlias]DEPRECATED_TYPING_ALIASESc              #  L   K   | ]}|                     d           d         V   dS ).   N)split).0keys     r   	<genexpr>r,   M   s1      OOc		#q)OOOOOOr   )OptionalUnionc                  <    e Zd ZU ded<   ded<   ded<   dZded<   d	S )
DeprecatedTypingAliasMsgnodes.Name | nodes.Attributenoder   qnamealiasFr   parent_subscriptN)r   r   r   r   r5   r   r   r   r0   r0   Q   sB         &&&&JJJJJJ"""""""r   r0   c                      e Zd ZU dZdZddddddd	Zd
dddddffZded<   	 ded<   	 dA fdZdBdZ	dCdZ
 edddd d!          dDd#            Z edddd d!          dEd%            Z ed&          dFd(            ZedGd+            ZdHd,ZedId.            Z	 dJdKd5ZdLd7ZdMd:ZdNd;Z edd          dOd=            ZdNd>ZdNd?ZdPd@Z xZS )QTypingCheckerz4Find issue specifically related to type annotations.typing)z$'%s' is deprecated, use '%s' insteaddeprecated-typing-aliasz/Emitted when a deprecated typing alias is used.)z@'%s' will be deprecated with PY39, consider using '%s' instead%sconsider-using-aliasz|Only emitted if 'runtime-typing=no' and a deprecated typing alias is used in a type annotation context in Python 3.7 or 3.8.)z9Consider using alternative Union syntax instead of '%s'%s!consider-alternative-union-syntaxznEmitted when 'typing.Union' or 'typing.Optional' is used instead of the alternative Union syntax 'int | None'.)z;'NoReturn' inside compound types is broken in 3.7.0 / 3.7.1broken-noreturnz``typing.NoReturn`` inside compound types is broken in Python 3.7.0 and 3.7.1. If not dependent on runtime introspection, use string annotation instead. E.g. ``Callable[..., 'NoReturn']``. https://bugs.python.org/issue34921)zo'collections.abc.Callable' inside Optional and Union is broken in 3.9.0 / 3.9.1 (use 'typing.Callable' instead)broken-collections-callablez``collections.abc.Callable`` inside Optional and Union is broken in Python 3.9.0 and 3.9.1. Use ``typing.Callable`` for these cases instead. https://bugs.python.org/issue42965)zVType `%s` is used more than once in union type annotation. Remove redundant typehints.redundant-typehint-argumentziDuplicated type arguments will be skipped by `mypy` tool, therefore should be removed to avoid confusion.)W6001R6002R6003E6004E6005R6006zruntime-typingTynz<y or n>au  Set to ``no`` if the app / library does **NOT** need to support runtime introspection of type annotations. If you use type annotations **exclusively** for type checking of an application, you're probably fine. For libraries, evaluate if some users want to access the type hints at runtime first, e.g., through ``typing.get_type_hints``. Applies to Python versions 3.7 - 3.9)defaultr#   metavarhelpr   _should_check_typing_alias&_should_check_alternative_union_syntaxlinterr   returnNonec                    t                                          |           d| _        t                      | _        g | _        g | _        dS )zInitialize checker instance.rK   FN)super__init___found_broken_callable_locationr!   _alias_name_collisions_deprecated_typing_alias_msgs_consider_using_alias_msgs)selfrK   	__class__s     r   rQ   zTypingChecker.__init__   sH    '''5:,03#MO*JL'''r   c                .   | j         j        j        }|dk    | _        |dk    | _        |dk    | _        | j        p| j        o| j         j        j        du | _        | j        p| j        o| j         j        j        du | _        |dk     | _	        |dk     | _
        d S )N)      )rY   	   )rY   
   F)rY   rZ      )rY   r[   r]   )rK   config
py_version
_py37_plus
_py39_plus_py310_plusruntime_typingrI   rJ   _should_check_noreturn_should_check_callable)rV   r_   s     r   openzTypingChecker.open   s    ['2
$.$.%0*./ +
OJ 2 AU J 	' 7;6F 7
OJ 2 AU J 	3 '19&<#&09&<###r   r2   nodes.NodeNGr   c                N    | j         sd|                                j        v rdS dS )z3Message hint if postponed evaluation isn't enabled.r    z2. Add 'from __future__ import annotations' as well)rb   rootfuture_importsrV   r2   s     r   _msg_postponed_eval_hintz&TypingChecker._msg_postponed_eval_hint   s-     	}		0JJJ2CCr   r9   r:   r;   r<   r=   
nodes.Namec                ^   | j         r#|j        t          v r|                     |           | j        r)|j        t
          v r|                     ||j                   | j        r |j        dk    r|                     |           | j	        r"|j        dk    r| 
                    |           d S d S d S NNoReturnCallable)rI   r   ALIAS_NAMES_check_for_typing_aliasrJ   UNION_NAMES#_check_for_alternative_union_syntaxrd   _check_broken_noreturnre   _check_broken_callablerl   s     r   
visit_namezTypingChecker.visit_name   s     * 	/tyK/G/G((...6 	F49;S;S44T49EEE& 	.49
+B+B''---& 	.49
+B+B''-----	. 	.+B+Br   nodes.Attributec                ^   | j         r#|j        t          v r|                     |           | j        r)|j        t
          v r|                     ||j                   | j        r |j        dk    r|                     |           | j	        r"|j        dk    r| 
                    |           d S d S d S rp   )rI   attrnamers   rt   rJ   ru   rv   rd   rw   re   rx   rl   s     r   visit_attributezTypingChecker.visit_attribute   s     * 	/t}/K/K((...6 	J4=K;W;W44T4=III& 	.4=J+F+F''---& 	.4=J+F+F''-----	. 	.+F+Fr   r>   nodes.AnnAssignc                   |j         }|                     |d          r5|                     |          r|                     d|dt                     d S |                     |d          r,t          |j        t          j                  r|j        j	        }n-| 
                    |          r|                     |          }nd S |                     ||           d S )Nr-   r>   rM   r2   args
confidencer.   )
annotation_is_deprecated_union_annotation_is_optional_none_annotationadd_messager   
isinstanceslicer   Tupleelts_is_binop_union_annotation_parse_binops_typehints_check_union_types)rV   r2   r   typess       r   visit_annassignzTypingChecker.visit_annassign   s    _
//
JGG 	00<<   1##	 !    F//
GDD 	ekJ
 J
 	 $)EE,,Z88 	00<<EEFt,,,,,r   r   
union_namec                    t          | t          j                  o.t          | j        t          j                  o| j        j        |k    S N)r   r   	SubscriptvalueNamer   )r   r   s     r   r   z-TypingChecker._is_deprecated_union_annotation   sB    
 z5?33 4:+UZ884 %3	
r   c                D    | j         ot          |t          j                  S r   )rJ   r   r   BinOp)rV   r   s     r   r   z(TypingChecker._is_binop_union_annotation  s'    : 
z@
 @
 	
r   nodes.Subscriptc                \    t          | j        t          j                  o| j        j        d u S r   )r   r   r   Constr   )r   s    r   r   z*TypingChecker._is_optional_none_annotation
  s,     z'55X*:J:PTX:X	
r   N
binop_nodenodes.BinOptypehints_listlist[nodes.NodeNG] | Nonelist[nodes.NodeNG]c                   |pg }t          |j        t          j                  r/|                    |                     |j        |                     n|                    |j                   |                    |j                   |S r   )r   leftr   r   extendr   appendright)rV   r   r   s      r   r   z%TypingChecker._parse_binops_typehints  s     (-2jou{33 	3!!,,Z_nMM    !!*/222j.///r   r   c                    t                      }|D ]N}|                                }||v r|                     d||t                     9|                    |           Od S )Nr>   r   )r!   	as_stringr   r   add)rV   r   r   	types_settypehinttypehint_strs         r   r   z TypingChecker._check_union_types  s     EE	 
	, 
	,H#--//Ly((  1#&#	 !     l++++
	, 
	,r   r1   r   c                   t          |          }t          |t          j                  r|                                dv s9t          |t
          j        j                  r|                                dk    sdS | j        st          |          sdS | 
                    d|||                     |          ft                     dS )zCheck if alternative union syntax could be used.

        Requires
        - Python 3.10
        - OR: Python 3.7+ with postponed evaluation in
              a type annotation context
           typing.Uniontyping.Optionaltyping._SpecialFormNr;   r   )r   r   r   FunctionDefr3   astroidbasesInstancerb   r	   r   rm   r   )rV   r2   r   inferreds       r   rv   z1TypingChecker._check_for_alternative_union_syntax-  s     d##x!233	  $GGG(GM$:;; H  $999F  	$Ft$L$L 	F/55d;;< 	 	 	
 	
 	
 	
 	
r   c                >   t          |          }t          |t          j                  sdS t                              |                                d          }|dS | j        rv|                                dk    r|                     |          rd| _	        | j
                            t          ||                                |j                             dS t          |          sVt          |j        t          j                  r7|j        du r,| j                            |                                           dS | j                            t          ||                                |j        t          |j        t          j                                       dS )a  Check if typing alias is deprecated or could be replaced.

        Requires
        - Python 3.9
        - OR: Python 3.7+ with postponed evaluation in
              a type annotation context

        For Python 3.7+: Only emit message if change doesn't create
            any name collisions, only ever used in a type annotation
            context, and can safely be replaced.
        Nr$   T)r   r   r   ClassDefr%   getr3   ra   _broken_callable_locationrR   rT   r   r0   r   r	   parentr   r   rS   r   rU   )rV   r2   r   r4   s       r   rt   z%TypingChecker._check_for_typing_aliasJ  s    d##(EN33 	F)--hnn.>.>EE=F? 	~~#4449W9W: :4 8<4.55(NN$$J    F 2$77 	JK=
 =
 	 #t+++//0@0@AAAF'..$  
4;88	 	
 	
 	
 	
 	
r   nodes.Modulec                .   | j         rM| j        D ]D}| j        r|j        dk    r|                     d|j        |j        |j        ft                     Enn| j        rg| 	                    |          }| j
        D ]J}|j        | j        v r|                     d|j        |j        |j        |j        r|ndft                     Kd| _        | j                                         | j                                         | j
                                         dS )zAfter parsing of module is complete, add messages for
        'consider-using-alias' check.

        Make sure results are safe to recommend / collision free.
        r$   r9   r   r:   ri   FN)ra   rT   rR   r3   r   r2   r4   r   r`   rm   rU   rS   r5   clear)rV   r2   msgmsg_future_imports       r   leave_modulezTypingChecker.leave_module~  s]    ? 	9  8	%666  -)SY/(	 !     _ 	 $ = =d C C6  9 ;;;  *		-0-AI))r
  ) ! 	 	 	 	 05,*00222#))+++'--/////r   c                L   t          |j        t          j                  sdS t	          |          st          |          rt          |          rdS |                                D ]}t          |t          j        t          j	        f          r|
                                t          v s[t          |t          j        j                  r\t          |j        t          j	                  r=|j        
                                dk    r |                     d|t"                      dS dS )z+Check for 'NoReturn' inside compound types.Nr   r<   r2   r   )r   r   r   BaseContainerr   r
   r	   inferr   r   r3   r   r   r   BaseInstance_proxiedr   r   rV   r2   r   s      r   rw   z$TypingChecker._check_broken_noreturn  s   $+u':;; 	F #4((	.t44	 3488	
 F

 	 	H 8e&7%HII	NN$$77h(BCC 8 x0%.AA 8 %++--1FFF  !2) TTT	 	r   c                    t          |          }t          |t          j                  r-|                                dk    r|                     |          sdS |                     d|t                     dS )z?Check for 'collections.abc.Callable' inside Optional and Union.z_collections_abc.CallableNr=   r   )r   r   r   r   r3   r   r   r   r   s      r   rx   z$TypingChecker._check_broken_callable  sy    d##x00	  $???..t44 @ F6TiXXXXXr   c                r   t          |          st          |          rt          |          rdS t          |j        t
          j                  rut          |j        j        t
          j                  rQt          |j        j        j
                  dk    r/t          |j        j        j
        d         t
          j                  sdS |j        j        }t          |t
          j                  r|j        }t          |t
          j                  r+t          |j        t
          j        t
          j        f          sdS t!          |j                  }t          |t
          j                  r|                                dv s9t          |t&          j        j                  r|                                dk    sdS dS )zFCheck if node would be a broken location for collections.abc.Callable.Fr]   r   r   r   T)r   r
   r	   r   r   r   r   r   r   lenr   Listr   r   r   	Attributer   r   r3   r   r   r   )rV   r2   r5   inferred_parents       r   r   z'TypingChecker._broken_callable_location  s    #4((	.t44	 3488	
 5 t{EO44	4;,ek::	 DK%*++q004;,1!4ejAA 1 5  ;-&(;<< 	7/6'99	+1EJ3PQQ	 5$%5%;<<(9::	%%''+NNN/7=+ABB O%%''+@@@5tr   rK   r   rL   rM   )rL   rM   )r2   rg   rL   r   )r2   rn   rL   rM   )r2   rz   rL   rM   )r2   r~   rL   rM   )r   rg   r   r   rL   r   )r   rg   rL   r   )r   r   rL   r   r   )r   r   r   r   rL   r   )r   r   r   rg   rL   rM   )r2   r1   r   r   rL   rM   )r2   r1   rL   rM   )r2   r   rL   rM   )r2   r1   rL   r   )r   r   r   __doc__r   msgsoptionsr   rQ   rf   rm   r   ry   r}   r   staticmethodr   r   r   r   r   rv   rt   r   rw   rx   r   __classcell__)rW   s   @r   r7   r7   X   s        >>D






G) )DX %; 	
G( %$$$ 1000M M M M M M= = = = D D D D  !+% . . . .  !+% . . . .   =>>- - - ?>-, 
 
 
 \

 
 
 

 
 
 
 \
 TX    , , , , 
 
 
 
:2
 2
 2
 2
h   68QRR(0 (0 (0 SR(0T   4
Y 
Y 
Y 
Y% % % % % % % %r   r7   rK   r   rL   rM   c                J    |                      t          |                      d S r   )register_checkerr7   rO   s    r   registerr     s$    
M&1122222r   r   ) 
__future__r   r8   r   r   astroid.basesr   r   pylint.checkersr   pylint.checkers.utilsr   r	   r
   r   r   pylint.constantsr   pylint.interfacesr   r   pylint.lintr   r   r%   r   r"   rs   ru   r0   r7   r   r   r   r   <module>r      s  
 # " " " " " " , , , , , , , ,           ' ' ' ' ' '              - , , , , , - - - - - - - - %$$$$$$    *   
+5KK//+5;;vu--+5 ;;vu--+5 ++eU++	+5
 K77+5 ;;vu--+5 KK 3T::+5 ++&?FF+5 ++&?FF+5 kk"7>>+5 {{#94@@+5 $?FF+5 $?FF+5 KK(GNN+5 KK(GNN+5  [[)I4PP!+5" {{#=tDD#+5 +5$ {{#=tDD%+5& $?FF'+5( %A4HH)+5* $?FF++5, %A4HH-+5. {{#=tDD/+50 ++&;UCC1+52 %A4HH3+54 kk";TBB5+56 [[)I4PP7+58 {{#=tDD9+5: kk*KTRR;+5< %A4HH=+5> ++&CTJJ?+5@ {{#=tDDA+5B $?FFC+5D %A4HHE+5 +5F )[)LeTT"-+0%# # "k,55K
D11"{#=tDDK 7>>U+5 +5 +5  + + + +Z iOO5NOOOOO## # # # #z # # #\ \ \ \ \K \ \ \~3 3 3 3 3 3r   