U
    dZ                     @   s  d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm	Z	m
Z
mZmZmZ dZd dlmZ edeeef dZeegef Zeddd	d
deeedddZedd	d
eeeedddZd dd	d
e	e eeeeef dddZed!dd	d
deeedddZedd	d
eeeedddZd"dd	d
e	e eeeeef dddZeeeedddZdd Zdd Zeee  dddZdd ZdS )#    N)FunctionType)CallableListOptionalTupleTypeVarUnionoverloadz7.4.0)ensure_signature_is_compatible_WrappedMethod)ZboundTFcheck_signaturecheck_at_runtime)methodr   r   returnc                C   s   d S N r   r   r   r   r   2lib/python3.8/site-packages/overrides/overrides.py	overrides    s    r   c                C   s   d S r   r   r   r   r   r   r   *   s    c                C   s(   | dk	rt | ||S tjt||dS dS )a0  Decorator to indicate that the decorated method overrides a method in
    superclass.
    The decorator code is executed while loading class. Using this method
    should have minimal runtime performance implications.

    How to use:
    from overrides import overrides

    class SuperClass(object):
        def method(self):
          return 2

    class SubClass(SuperClass):

        @overrides
        def method(self):
            return 1

    :param check_signature: Whether or not to check the signature of the overridden method.
    :param check_at_runtime: Whether or not to check the overridden method at runtime.
    :raises AssertionError: if no match in super classes for the method name
    :return: method with possibly added (if the method doesn't have one)
        docstring from super class
    Nr   
_overrides	functoolspartialr   r   r   r   r   r   4   s    c                C   s   d S r   r   r   r   r   r   override\   s    r   c                C   s   d S r   r   r   r   r   r   r   f   s    c                C   s(   | dk	rt | ||S tjt||dS dS )a.  Decorator to indicate that the decorated method overrides a method in
    superclass.
    The decorator code is executed while loading class. Using this method
    should have minimal runtime performance implications.

    How to use:
    from overrides import override

    class SuperClass(object):
        def method(self):
          return 2

    class SubClass(SuperClass):

        @override
        def method(self):
            return 1

    :param check_signature: Whether or not to check the signature of the overridden method.
    :param check_at_runtime: Whether or not to check the overridden method at runtime.
    :raises AssertionError: if no match in super classes for the method name
    :return: method with possibly added (if the method doesn't have one)
        docstring from super class
    Nr   r   r   r   r   r   r   p   s    c                    s   t dd tdd }|d kr0ttjj }ttd|D ]Jtj	r@|rvt
 fdd}|  S t    S q@tj dd S )NZ__override__T__globals__   c                     s   t   | |S r   )_validate_method)argskwargsr   r   super_classr   r   wrapper   s    z_overrides.<locals>.wrapperz: No super class method found)setattrgetattrvarssysmodules
__module___get_base_classes	_getframehasattr__name__r   wrapsr   	TypeError__qualname__)r   r   r   Zglobal_varsr"   r   r    r   r      s    
r   c                 C   sx   t || j}tt|| jt}t |ddr@t| j d| | jsN|j| _|rt| jdstt|t	stt
|| | d S )NZ	__final__Fz: is finalized in __)r$   r,   
isinstanceinspectZgetattr_staticstaticmethodr.   __doc__
startswithpropertyr
   )r   r!   r   Zsuper_methodZ	is_staticr   r   r   r      s      
r   c                    s    fddt | D S )Nc                    s   g | ]}t | qS r   )_get_base_class).0Zclass_name_components	namespacer   r   
<listcomp>   s   z%_get_base_classes.<locals>.<listcomp>)_get_base_class_names)framer:   r   r9   r   r)      s    
r)   )r   c                 C   s   g }d}t | jD ]}|j| jkr( q|jt jkr6q|sBg }d}|jdkr^|d|j	f q|jdkrz|d|j	f q|jdkr|d|j	f qd}qg }g }|D ]0\}}|dkr|r|| |g}q||g7 }q|r|| |S )z(Get baseclass names from the code objectTZ	LOAD_NAMEnameZ	LOAD_ATTRattrZLOAD_GLOBALF)
disZget_instructionsf_codeoffsetf_lastiZopcodeZhasnameopnameappendZargval)r=   ZextendsZadd_last_stepZinstructionitemsZprevious_itemtsr   r   r   r<      s8    




r<   c                 C   s   z|| d  }W nF t k
rV   t|d tr@|d | d  }nt|d | d }Y nX | dd  D ]}t||rdt||}qd|S )Nr   __builtins__   )KeyErrorr1   dictr$   r+   )Z
componentsr:   objZ	componentr   r   r   r7      s    
r7   )N)N)N)N)r@   r   r2   r&   typesr   typingr   r   r   r   r   r   r	   Z__VERSION__Zoverrides.signaturer
   r   Z_DecoratorMethodboolr   r   r   r   r)   strr<   r7   r   r   r   r   <module>   s   $ 	
 
( 	
 
)  #