
    .Kf                         d Z ddlZddlZ eed      rej                  Zyej
                  Zej                  Z G d de      Zy)zBackport of @functools.singledispatchmethod to Python <3.7.

Adapted from https://github.com/ikalnytskyi/singledispatchmethod
removing 2.7 specific code.
    Nsingledispatchmethodc            	          e Zd ZdZdej
                  dej                  f   ddfdZ	 ddej
                  dej                  f   dej                  ej
                  dej                  f      dej
                  dej                  f   fd	Z	d
ej                  dej
                  ej                  gej                  f   dej
                  dej                  f   fdZ
edej                  fd       Zy)r   a  Single-dispatch generic method descriptor.

        TODO: Figure out how to type this:

        `mypy --strict` returns errors like the following for all decorated methods:
        "Untyped decorator makes function "send" untyped."

        But this is not a normal function-base decorator, it's a class and it
        doesn't have a __call__ method. When decorating the "base" method
        __init__ is called, but of course its return type is None.
        func.returnNc                     t        |      s&t        |d      st        dj                  |            t	        |      | _        || _        y )N__get__z${!r} is not callable or a descriptor)callablehasattr	TypeErrorformatsingledispatch
dispatcherr   )selfr   s     I/var/www/html/Backend/venv/lib/python3.12/site-packages/socksio/compat.py__init__zsingledispatchmethod.__init__!   s<    D>'$	*B F M Md STT,T2DODI    clsmethodc                 <    | j                   j                  ||      S )a  Register a method on a class for a particular type.

            Note in Python <= 3.6 this methods cannot infer the type from the
            argument's type annotation, users *must* supply it manually on
            decoration, i.e.

            @my_method.register(TypeToDispatch)
            def _(self, arg: TypeToDispatch) -> None:
                ...

            Versus in Python 3.7+:

            @my_method.register
            def _(self, arg: TypeToDispatch) -> None:
                ...

            )r   )r   register)r   r   r   s      r   r   zsingledispatchmethod.register(   s    4 ??++Cf+==r   objc                      dt         j                  dt         j                  dt         j                  f fd} j                  |_         j                  |_        t	        | j
                         |S )Nargskwargsr   c                      j                   j                  | d   j                        } |j                        | i |S )Nr   )r   dispatch	__class__r   )r   r   r   r   r   r   s      r   _methodz-singledispatchmethod.__get__.<locals>._methodG   s>    11$q'2C2CD/v~~c3/@@@r   )typingAny__isabstractmethod__r   update_wrapperr   )r   r   r   r   s   ``` r   r   zsingledispatchmethod.__get__D   s\    Avzz AVZZ AFJJ A ,0+D+DG(#}}G7DII.Nr   c                 0    t        | j                  dd      S )Nr!   F)getattrr   )r   s    r   r!   z)singledispatchmethod.__isabstractmethod__T   s    499&<eDDr   )N)__name__
__module____qualname____doc__r   Callabler    r   Optionalr   r   propertyr!    r   r   r   r      s    
		fjj!A 	d 	 IM	>fjj1	> OOFOOCO$DE	> __S&**_-		>8	zz	(.fjj8P(Q	__S&**_-	  
	E&** 	E 
	Er   )r(   	functoolsr   r
   r   r"   r   objectr,   r   r   <module>r/      sO     
9,-$99--N--NBEv BEr   