U
    Vh                     @   sF   d Z ddlZddlZeedr&ejZnejZejZG d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                   @   s   e Zd ZdZejdejf ddddZdejdejf ejejdejf  ejdejf ddd	Z	ejejejgejf ejdejf d
ddZ
eejdd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.
        .N)funcreturnc                 C   s4   t |s t|ds td|t|| _|| _d S )N__get__z${!r} is not callable or a descriptor)callablehasattr	TypeErrorformatsingledispatch
dispatcherr   )selfr    r   P/var/www/html/arya_register/venvv2/lib/python3.8/site-packages/socksio/compat.py__init__!   s    
zsingledispatchmethod.__init__)clsmethodr   c                 C   s   | j j||d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   r   r   r   r   (   s    zsingledispatchmethod.register)objr   r   c                    s@   t jt jt jd fdd}j|_j|_t|j |S )N)argskwargsr   c                     s$   j | d j}| | |S )Nr   )r   dispatch	__class__r   )r   r   r   r   r   r   r   r   _methodG   s    z-singledispatchmethod.__get__.<locals>._method)typingAny__isabstractmethod__r   update_wrapperr   )r   r   r   r   r   r   r   r   D   s
     zsingledispatchmethod.__get__)r   c                 C   s   t | jddS )Nr   F)getattrr   )r   r   r   r   r   T   s    z)singledispatchmethod.__isabstractmethod__)N)__name__
__module____qualname____doc__r   Callabler   r   Optionalr   r   propertyr   r   r   r   r   r      s   
  )r"   	functoolsr   r   r   r   r
   objectr   r   r   r   <module>   s   
