
    c                         d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddl
mZ dd	l
mZ dd
l
mZ ddl
mZ ddlmZmZmZ ddgZefZddZd ZddZddZej         e_         dZ eef          Zd Zd ZdS )z!Verify interface implementations
    )print_functionN)FunctionType)
MethodType)PYPY2)BrokenImplementation)BrokenMethodImplementation)DoesNotImplement)Invalid)MultipleInvalid)
fromMethodfromFunctionMethodverifyObjectverifyClassFc                    |dk    r| j         }n| j        }g }|s. ||          s#|                    t          | |                     |                     d          D ]E\  }}	 t          | ||||           # t          $ r}|                    |           Y d}~>d}~ww xY w|r,t          |          dk    r|d         t          | ||          dS )a  
    Verify that *candidate* might correctly provide *iface*.

    This involves:

    - Making sure the candidate claims that it provides the
      interface using ``iface.providedBy`` (unless *tentative* is `True`,
      in which case this step is skipped). This means that the candidate's class
      declares that it `implements <zope.interface.implementer>` the interface,
      or the candidate itself declares that it `provides <zope.interface.provider>`
      the interface

    - Making sure the candidate defines all the necessary methods

    - Making sure the methods have the correct signature (to the
      extent possible)

    - Making sure the candidate defines all the necessary attributes

    :return bool: Returns a true value if everything that could be
       checked passed.
    :raises zope.interface.Invalid: If any of the previous
       conditions does not hold.

    .. versionchanged:: 5.0
        If multiple methods or attributes are invalid, all such errors
        are collected and reported. Previously, only the first error was reported.
        As a special case, if only one such error is present, it is raised
        alone, like before.
    cT)allN   r   )	implementedBy
providedByappendr	   namesAndDescriptions_verify_elementr
   lenr   )	iface	candidate	tentativevtypetesterexcsnamedesces	            5lib/python3.11/site-packages/zope/interface/verify.py_verifyr%   *   s   @ | "$!D 8VVI.. 8$UI6677700T0::  
d	E4y%@@@@ 	 	 	KKNNNNNNNN	  6t99> 	q'MeY5554s   $A88
B!BB!c                    	 t          ||          }n=# t          $ r0 t          |t                    s	|dk    rY d S t	          | ||          w xY wt          |t                    sd S t          j        |          st          j        |          rd S t          |t                    rXt          j
        d         dk    r/t          |t                    r|dk    rt          || |d          }nt          || |          }nt          |t                    r-t          |j                  t          u rt          || |          }nAt          |t                     r|dk    rd S t#          |          st%          |d|| |          d S t'          |                                |                                          }|r-t*          rt-          |||          rd S t%          |||| |          d S )Nr   r      r   )r!   imlevel)r!   zimplementation is not a method)getattrAttributeError
isinstancer   r   inspectismethoddescriptor	isbuiltinr   sysversion_infotyper   MethodTypes__func__r   propertycallabler   	_incompatgetSignatureInfor   _pypy2_false_positive)r   r!   r"   r   r   attrmethmesss           r$   r   r   `   s;   ;y$'' ; ; ;4(( 	esl 	 FF"5$	:::; dF## !$'' 7+<T+B+B  	$%% A!# 		8
9d(C(C 		8QT 		8
  e$()+ + +DD  e$777DD
T;
'
' 4=!!\1$t,,	D(	#	#  
 	 ~~ 	E,T3S-15)E E E 	 T**,,d.C.C.E.EFFD M 	*4EBB 	F(tT5)LLLM Ms    %AAc                 (    t          | ||d          S )zF
    Verify that the *candidate* might correctly provide *iface*.
    r   r   r%   r   r   r   s      r$   r   r      s     5)Yc::::    c                 (    t          | ||d          S )Nor=   r>   r?   s      r$   r   r      s    5)Yc::::r@   z*implementation requires too many argumentsc                     | t           vrdS t          t                                                    }|dk    r|nt	          |          }||v rdS dS )NFr   T)_KNOWN_PYPY2_FALSE_POSITIVESvars__builtins__valuesr1   )msgr   r   known_builtin_typescandidate_types        r$   r8   r8      sa     .. u|,,3355"'3,CYYDOON,, t5r@   c                 $   t          |d                   t          | d                   k    rt          S t          |d                   t          | d                   k     r
|d         sdS | d         r
|d         sdS | d         r
|d         sdS d S d S )Nrequired
positionalvarargsz-implementation doesn't allow enough argumentskwargsz0implementation doesn't support keyword argumentsz1implementation doesn't support variable arguments)r   _MSG_TOO_MANY)rL   implementeds     r$   r6   r6      s    
 ;z"##c(:*>&?&?? 	[&	'	'#h|.D*E*E	E ?I&?>> B+h"7 BAA	 C;y#9 CBBC C C Cr@   )FN)F)__doc__
__future__r   r,   r/   typesr   r   zope.interface._compatr   zope.interface.exceptionsr   r   r	   r
   r   zope.interface.interfacer   r   r   __all__r2   r%   r   r   r   rP   	frozensetrD   r8   r6    r@   r$   <module>r[      s    % % % % % %  



             ( ( ( ( ( ( : : : : : : @ @ @ @ @ @ 6 6 6 6 6 6 - - - - - - 5 5 5 5 5 5 E E E E E E E E E E  n4 4 4 4lAM AM AMJ; ; ; ;; ; ; ;  <(y*     
  .C C C C Cr@   