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

Adapted from https://github.com/ikalnytskyi/singledispatchmethod
removing 2.7 specific code.
    Nsingledispatchmethodc            	       x   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dS )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          |          s2t          |d          s"t          d                    |                    t	          |          | _        || _        d S )N__get__z${!r} is not callable or a descriptor)callablehasattr	TypeErrorformatsingledispatch
dispatcherr   )selfr   s     U/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/socksio/compat.py__init__zsingledispatchmethod.__init__!   sZ    D>> U'$	*B*B U F M Md S STTT,T22DODIII    clsmethodc                 :    | 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                             | d         j                  } |                              | i |S )Nr   )r   dispatch	__class__r   )r   r   r   r   r   r   s      r   _methodz-singledispatchmethod.__get__.<locals>._methodG   sB    11$q'2CDD/v~~c3//@@@@r   )typingAny__isabstractmethod__r   update_wrapperr   )r   r   r   r   s   ``` r   r   zsingledispatchmethod.__get__D   s    Avz AVZ AFJ A A A A A A A A ,0+DG(#}G7DI...Nr   c                 .    t          | j        dd          S )Nr!   F)getattrr   )r   s    r   r!   z)singledispatchmethod.__isabstractmethod__T   s    49&<eDDDr   )N)__name__
__module____qualname____doc__r   Callabler    r   Optionalr   r   propertyr!    r   r   r   r      s4       
	 
		fj!A 	d 	 	 	 	 IM	> 	>fj1	> OFOCO$DE	> _S&*_-		> 	> 	> 	>8	z	(.fj8P(Q	_S&*_-	 	 	 	  
	E&* 	E 	E 	E 
	E 	E 	Er   )r(   	functoolsr   r
   r   r"   r   objectr,   r   r   <module>r/      s         
79,-- LE$9-N-NBE BE BE BE BEv BE BE BE BE BEr   