o
    VÌh/  ã                   @  s  U d dl mZ d dlmZmZmZmZmZ edƒZedƒZ	ernd dl
mZ d dlmZmZ d dlmZmZ edef Zd	ed
< eeg ef Zd	ed< eee egdf Zd	ed< eeegdf Zd	ed< G dd„ dee ƒZG dd„ deee	f ƒZG dd„ dee ƒZdS )é    )Úannotations)ÚTYPE_CHECKINGÚGenericÚTypeVarÚcastÚoverloadÚ_TÚ_U)ÚCallable)ÚAnyÚProtocol)ÚSelfÚ	TypeAlias.r   Ú_GetterCallableÚ_GetterClassMethodNÚ_SetterCallableÚ_SetterClassMethodc                   @  s"   e Zd Zdddd	„Zddd„ZdS )Ú_ClassPropertyAttributeNÚobjÚobjectÚobjtypeútype[Any] | NoneÚreturnr   c                 C  ó   d S ©N© ©Úselfr   r   r   r   úm/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/jaraco/classes/properties.pyÚ__get__   ó    z_ClassPropertyAttribute.__get__ÚvalueÚNonec                 C  r   r   r   )r   r   r!   r   r   r   Ú__set__   r    z_ClassPropertyAttribute.__set__r   )r   r   r   r   r   r   )r   r   r!   r   r   r"   )Ú__name__Ú
__module__Ú__qualname__r   r#   r   r   r   r   r      s    r   c                   @  sH   e Zd ZdZddd„Zeddd„ƒZe	dddd„ƒZ	dddd„ZdS )ÚNonDataPropertya  Much like the property builtin, but only implements __get__,
    making it a non-data property, and can be subsequently reset.

    See http://users.rcn.com/python/download/Descriptor.htm for more
    information.

    >>> class X(object):
    ...   @NonDataProperty
    ...   def foo(self):
    ...     return 3
    >>> x = X()
    >>> x.foo
    3
    >>> x.foo = 4
    >>> x.foo
    4

    '...' below should be 'jaraco.classes' but for pytest-dev/pytest#3396
    >>> X.foo
    <....properties.NonDataProperty object at ...>
    ÚfgetúCallable[[_T], _U]r   r"   c                 C  s*   |d usJ dƒ‚t |ƒsJ dƒ‚|| _d S )Nzfget cannot be nonezfget must be callable)Úcallabler(   )r   r(   r   r   r   Ú__init__2   s   
zNonDataProperty.__init__r   r   r   c                 C  r   r   r   r   r   r   r   r   7   ó   zNonDataProperty.__get__Nr   útype[_T] | Noner	   c                 C  r   r   r   r   r   r   r   r   >   r,   ú	_T | Noneú	Self | _Uc                 C  s   |d u r| S |   |¡S r   )r(   r   r   r   r   r   E   s   
)r(   r)   r   r"   )r   r"   r   r"   r   r   r   )r   r   r   r-   r   r	   )r   r.   r   r-   r   r/   )r$   r%   r&   Ú__doc__r+   r   r   r   r   r   r   r'      s    
ý	ýr'   c                   @  s’   e Zd ZU dZded< ded< G dd„ deƒZ	d&d'dd„Zd&d(dd„Zd)dd„Z	d*dd„Z
eed+dd „ƒƒZeed,d"d „ƒƒZed-d%d „ƒZdS ).ÚclasspropertyaÚ  
    Like @property but applies at the class level.


    >>> class X(metaclass=classproperty.Meta):
    ...   val = None
    ...   @classproperty
    ...   def foo(cls):
    ...     return cls.val
    ...   @foo.setter
    ...   def foo(cls, val):
    ...     cls.val = val
    >>> X.foo
    >>> X.foo = 3
    >>> X.foo
    3
    >>> x = X()
    >>> x.foo
    3
    >>> X.foo = 4
    >>> x.foo
    4

    Setting the property on an instance affects the class.

    >>> x.foo = 5
    >>> x.foo
    5
    >>> X.foo
    5
    >>> vars(x)
    {}
    >>> X().foo
    5

    Attempting to set an attribute where no setter was defined
    results in an AttributeError:

    >>> class GetOnly(metaclass=classproperty.Meta):
    ...   @classproperty
    ...   def foo(cls):
    ...     return 'bar'
    >>> GetOnly.foo = 3
    Traceback (most recent call last):
    ...
    AttributeError: can't set attribute

    It is also possible to wrap a classmethod or staticmethod in
    a classproperty.

    >>> class Static(metaclass=classproperty.Meta):
    ...   @classproperty
    ...   @classmethod
    ...   def foo(cls):
    ...     return 'foo'
    ...   @classproperty
    ...   @staticmethod
    ...   def bar():
    ...     return 'bar'
    >>> Static.foo
    'foo'
    >>> Static.bar
    'bar'

    *Legacy*

    For compatibility, if the metaclass isn't specified, the
    legacy behavior will be invoked.

    >>> class X:
    ...   val = None
    ...   @classproperty
    ...   def foo(cls):
    ...     return cls.val
    ...   @foo.setter
    ...   def foo(cls, val):
    ...     cls.val = val
    >>> X.foo
    >>> X.foo = 3
    >>> X.foo
    3
    >>> x = X()
    >>> x.foo
    3
    >>> X.foo = 4
    >>> x.foo
    4

    Note, because the metaclass was not specified, setting
    a value on an instance does not have the intended effect.

    >>> x.foo = 5
    >>> x.foo
    5
    >>> X.foo  # should be 5
    4
    >>> vars(x)  # should be empty
    {'foo': 5}
    >>> X().foo  # should be 5
    4
    z/_ClassPropertyAttribute[_GetterClassMethod[_T]]r(   z6_ClassPropertyAttribute[_SetterClassMethod[_T] | None]Úfsetc                      s   e Zd Zd	‡ fdd„Z‡  ZS )
zclassproperty.MetaÚkeyÚstrr!   r   r   r"   c                   s4   | j  |d ¡}t|ƒtu r| | |¡S tƒ  ||¡S r   )Ú__dict__ÚgetÚtyper1   r#   ÚsuperÚ__setattr__)r   r3   r!   r   ©Ú	__class__r   r   r9   º   s   zclassproperty.Meta.__setattr__)r3   r4   r!   r   r   r"   )r$   r%   r&   r9   Ú__classcell__r   r   r:   r   ÚMeta¹   s    r=   Nú,_GetterCallable[_T] | _GetterClassMethod[_T]ú3_SetterCallable[_T] | _SetterClassMethod[_T] | Noner   r"   c                 C  s*   |   |¡| _|| _|o|  |¡ d S  d S r   )Ú_ensure_methodr(   r2   Úsetter)r   r(   r2   r   r   r   r+   À   s   zclassproperty.__init__Úinstancer   Úownerútype[object] | Noner   c                 C  s   | j  d |¡ƒ S r   )r(   r   )r   rB   rC   r   r   r   r   É   s   zclassproperty.__get__r!   c                 C  s<   | j stdƒ‚t|ƒtjurt|ƒ}| j  d td|ƒ¡|ƒS )Nzcan't set attributeztype[object])r2   ÚAttributeErrorr7   r1   r=   r   r   )r   rC   r!   r   r   r   r#   Ì   s
   zclassproperty.__set__ú,_SetterCallable[_T] | _SetterClassMethod[_T]r   c                 C  s   |   |¡| _| S r   )r@   r2   )r   r2   r   r   r   rA   Ó   s   zclassproperty.setterÚfnú_GetterClassMethod[_T]c                 C  r   r   r   ©ÚclsrG   r   r   r   r@   ×   r,   zclassproperty._ensure_methodú_SetterClassMethod[_T]c                 C  r   r   r   rI   r   r   r   r@   Þ   r,   ú[_GetterCallable[_T] | _GetterClassMethod[_T] | _SetterCallable[_T] | _SetterClassMethod[_T]ú/_GetterClassMethod[_T] | _SetterClassMethod[_T]c                 C  s    t |ttfƒ }|rt|ƒS |S )z=
        Ensure fn is a classmethod or staticmethod.
        )Ú
isinstanceÚclassmethodÚstaticmethod)rJ   rG   Úneeds_methodr   r   r   r@   å   s   r   )r(   r>   r2   r?   r   r"   )rB   r   rC   rD   r   r   )rC   r   r!   r   r   r"   )r2   rF   r   r   )rG   r>   r   rH   )rG   rF   r   rK   )rG   rL   r   rM   )r$   r%   r&   r0   Ú__annotations__r7   r=   r+   r   r#   rA   r   rO   r@   r   r   r   r   r1   O   s$   
 f
ý	

r1   )Ú
__future__r   Útypingr   r   r   r   r   r   r	   Úcollections.abcr
   r   r   Útyping_extensionsr   r   r   rR   rO   r   r7   r   r   r   r'   r1   r   r   r   r   Ú<module>   s    4