U
    1ÜŸjv  ã                   @  sà   U d Z ddlmZ ddlZddlmZmZmZmZ ddl	m
Z
mZ edƒZeg ef Zddd	œd
d„Zddl	mZmZ ded< es¨edd„ eedeegƒi ƒeƒD ƒƒZdddœdd„Zdddddœdd„Zdddœdd„ZdS )zV
Workaround for U{the lack of TypeForm
<https://github.com/python/mypy/issues/9773>}.
é    )ÚannotationsN)ÚTYPE_CHECKINGÚCallableÚProtocolÚTypeVar)Ú	signatureÚ	SignatureÚTzProtocolAtRuntime[T]Ústr)ÚxÚreturnc                 C  s   | j S ©N)Ú__name__)r   © r   ú9/tmp/pip-unpacked-wheel-43vki919/automat/_runtimeproto.pyÚruntime_name   s    r   )Ú
getmembersÚ
isfunctionzfrozenset[str]ÚemptyProtocolMethodsc                 c  s   | ]\}}|V  qd S r   r   ©Ú.0ÚnameZeachr   r   r   Ú	<genexpr>   s   ÿr   ZExampleÚobject)Úprotocolr   c                 C  s   t dd„ t| tƒD ƒƒt S )zÔ
    Attempt to ignore implementation details, and get all the methods that the
    protocol actually defines.

    that includes locally defined methods and also those defined in inherited
    superclasses.
    c                 s  s   | ]\}}|V  qd S r   r   r   r   r   r   r   *   s     z1actuallyDefinedProtocolMethods.<locals>.<genexpr>)Ú	frozensetr   r   r   )r   r   r   r   ÚactuallyDefinedProtocolMethods!   s    	ÿÿr   zCallable[..., object]ÚNone)ÚmethodÚitÚannr   c                 C  s,   t ||ƒ}t|tƒr(t||t|| jƒƒ d S r   )ÚgetattrÚ
isinstancer
   ÚsetattrÚevalÚ__globals__)r   r   r    Ú
annotationr   r   r   Ú_fixAnnotation/   s    

r'   r   )r   r   c                 C  s4   t | ƒ}|j ¡ D ]}t| |dƒ qt| |dƒ |S )z5
    Get a signature with evaluated annotations.
    Ú_annotationÚ_return_annotation)r   Ú
parametersÚvaluesr'   )r   ÚresultÚparamr   r   r   Ú_liveSignature5   s
    r.   )Ú__doc__Ú
__future__r   ÚsysÚtypingr   r   r   r   Úinspectr   r   r	   ZProtocolAtRuntimer   r   r   Ú__annotations__r   ÚtypeÚtupler   r   r'   r.   r   r   r   r   Ú<module>   s    þ