
    Rǻi}                    &   d dl mZ d dlZd dlmZ d dlmZ ddlmZ	 ddlm
Z
 e	j                  r e	j                  de	j                  	      Zdefd
ZddZddZddZe	j                  r G d de	j&                        ZneZ	 	 	 	 	 	 ddZefdZy)    )annotationsN)wraps)warn   )_typing)PreviewWarning_FuncT)boundc                (     || t         |dz          y )Nr   category
stacklevel)DeprecationWarning)messagestack_level_warns      M/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/neo4j/_warnings.pydeprecation_warnr   !   s    	'.;?K    c                "    t        | t              S )a  
    Decorate deprecated functions and methods.

    ::

        @deprecated("'foo' has been deprecated in favour of 'bar'")
        def foo(x):
            pass

        @property
        @deprecated("'bar' will be internal without a replacement")
        def bar(self):
            return "bar"

        @property
        def baz(self):
            return self._baz

        @baz.setter
        @deprecated("'baz' will be read-only in the future")
        def baz(self, value):
            self._baz = value

    )_make_warning_decoratorr   r   s    r   
deprecatedr   %   s    2 #7,<==r   c                8    | dz  } t        | t        |dz          y )Nz It might be changed without following the deprecation policy. See also https://github.com/neo4j/neo4j-python-driver/wiki/preview-features.r   r   )r   r   )r   r   s     r   preview_warnr   A   s$    	NG
 	>kAoFr   c                "    t        | t              S )z
    Decorate functions and methods as preview.

    ::

        @preview("foo is a preview.")
        def foo(x):
            pass
    )r   r   r   s    r   previewr   J   s     #7L99r   c                      e Zd ZdddZy)_WarningFuncc                     y N )selfr   r   s      r   __call__z_WarningFunc.__call__Z   s    r   Nr   )r   strr   intreturnNone)__name__
__module____qualname__r$   r"   r   r   r   r   Y   s    Kr   r   c                      fd}|S )Nc                    t        j                         rt                fd       } |_        |S t        j                         rVt         d      r? j                  t              fd       }fd}| _        t        |       _         S t        d      t                fd       } |_        |S )Nc                 D   K    d        | i | d {   S 7 wN   )r   r"   argskwargsfr   warning_funcs     r   innerz9_make_warning_decorator.<locals>.decorator.<locals>.innerf   s'     W!4/////s     __init__c                0     d        | g|i |S r0   r"   )r#   r3   r4   r   original_initr6   s      r   r7   z9_make_warning_decorator.<locals>.decorator.<locals>.innerr   s"     a8(????r   c                L     | j                   | g|i |} |g|i | |S r!   )__new__)clsr3   r4   objr:   s       r   _without_warningzD_make_warning_decorator.<locals>.decorator.<locals>._without_warningw   s4    %#++c;D;F;C!#777Jr   z&Cannot decorate class without __init__c                 (     d        | i |S r0   r"   r2   s     r   r7   z9_make_warning_decorator.<locals>.decorator.<locals>.inner   s    W!4$)&))r   )	inspectiscoroutinefunctionr   r?   isclasshasattrr8   classmethod	TypeError)r5   r7   r?   r:   r   r6   s   `  @r   	decoratorz*_make_warning_decorator.<locals>.decoratorc   s    &&q)1X0 0 &'E"L??1q*% !

}%@ &@
 #
%01A%B"DEE 1X* * &'E"Lr   r"   )r   r6   rG   s   `` r   r   r   _   s    &P r   c                b    | j                   j                  }d| d| d} ||t        d|        y )Nz
unclosed  z: .r1   )r   source)	__class__r*   ResourceWarning)r>   r   cls_namemsgs       r   unclosed_resource_warnrO      s3    }}%%Hxj3'
+C	#1S9r   )r   r&   r(   t.Callable[[_FuncT], _FuncT]r%   )r(   rP   )r   r&   r6   r   r(   rP   )
__future__r   rA   	functoolsr   warningsr    r   tr   TYPE_CHECKINGTypeVarCallabler	   r   r   r   r   Protocolr   objectr   rO   r"   r   r   <module>r[      s   " #     $ ??QYYxqzz2F
 +,4 L>8G
: ??Lqzz L L,,, ",b '+ :r   