
    IiO                       % S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
JrJr  SSKJrJr  S*S jr " S S\5      r\" \" S	S
5      \" SS5      \" SS5      \" SS5      \" SS5      \" SS5      S9r0 rS\S'    " S S\5      r\ " S S\S95       r " S S\5      r " S S \5      r " S! S"\5      r " S# S$\5      r " S% S&\5      r " S' S(\5      rg))+     )annotations)total_ordering)Dict
NamedTupleOptionalTupleTypeUnioncast)ClassVarListc                b    [        U [        5      (       a  U R                  5       $ [        U 5      $ )z%
converts a byte/str or int to a str
)
isinstancebytesdecodestr)values    3/venv/lib/python3.13/site-packages/limits/limits.pysafe_stringr      s'    
 %||~u:    c                  *    \ rS rSr% S\S'   S\S'   Srg)Granularity   intsecondsr   name N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r   r   r   r   r      s    L
Ir   r   iQ dayi ' monthi yeari  hour<   minute   second)r%   r&   r'   r(   r*   r,   zDict[str, Type[RateLimitItem]]GRANULARITIESc                  <   ^  \ rS rSr        SU 4S jjrSrU =r$ )RateLimitItemMeta'   c                   > SU;  a  / US'   [         TU ]  XX#5      nSU;   a$  [        [        [           U5      [
        US   S   '   U$ )N	__slots__GRANULARITYr+   )super__new__r   r
   RateLimitItemr-   )clsr   parentsdctgranularity	__class__s        r   r5   RateLimitItemMeta.__new__(   sZ     c!!Cgoc>C37]#[4M#m,Q/0 r   r   )r   r   r8   zTuple[type, ...]r9   z(Dict[str, Union[Granularity, List[str]]]returnr/   )r   r    r!   r"   r5   r$   __classcell__)r;   s   @r   r/   r/   '   s3     " 6	
 
 r   r/   c                      \ rS rSr% Sr/ SQrS\S'     S     SS jjr\SS j5       r	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSrg)r6   ;   aA  
defines a Rate limited resource which contains the characteristic
namespace, amount and granularity multiples of the rate limiting window.

:param amount: the rate limit amount
:param multiples: multiple of the 'per' :attr:`GRANULARITY`
 (e.g. 'n' per 'm' seconds)
:param namespace: category for the specific rate limit
)	namespaceamount	multipleszClassVar[Granularity]r3   c                b    X0l         [        U5      U l        [        U=(       d    S5      U l        g )Nr+   )rA   r   rB   rC   )selfrB   rC   rA   s       r   __init__RateLimitItem.__init__O   s$     #&kY^!,r   c                P    UR                  5       U R                  R                  ;   $ )z
Checks if this instance matches a *granularity_string*
of type ``n per hour``, ``n per minute`` etc,
by comparing with :attr:`GRANULARITY`

)lowerr3   r   )r7   granularity_strings     r   check_granularity_string&RateLimitItem.check_granularity_stringV   s"     "'')S__-A-AAAr   c                H    U R                   R                  U R                  -  $ )z=
:return: the duration the limit is enforced for in seconds.
)r3   r   rC   rE   s    r   
get_expiryRateLimitItem.get_expirya   s    
 ''$..88r   c                   SR                  U Vs/ s H  n[        U5      PM     sn[        U R                  5      [        U R                  5      U R                  R
                  /-   5      nU R                   SU 3$ s  snf )z
Constructs a key for the current limit and any additional
identifiers provided.

:param identifiers: a list of strings to append to the key
:return: a string key identifying this resource with
 each identifier appended with a '/' delimiter.
/)joinr   rB   rC   r3   r   rA   )rE   identifiersk	remainders       r   key_forRateLimitItem.key_forh   sv     HH%01[[^[1DKK(DNN+  %%
	 ..!9+.. 2s   A=c                    [        U[        5      (       aY  U R                  UR                  :H  =(       a9    U R                  UR                  :H  =(       a    U R                  UR                  :H  $ g)NF)r   r6   rB   r3   rC   rE   others     r   __eq__RateLimitItem.__eq__|   sW    e]++u||+ 6$$(9(996NNeoo5
 r   c                f    U R                    SU R                   SU R                  R                   3$ )Nz per  )rB   rC   r3   r   rN   s    r   __repr__RateLimitItem.__repr__   s/    ++eDNN#31T5E5E5J5J4KLLr   c                \    U R                   R                  UR                   R                  :  $ N)r3   r   rZ   s     r   __lt__RateLimitItem.__lt__   s%    ''%*;*;*C*CCCr   c                p    [        U R                  U R                  U R                  U R                  45      $ rc   )hashrA   rB   rC   r3   rN   s    r   __hash__RateLimitItem.__hash__   s(    T^^T[[$..$BRBRSTTr   )rB   rC   rA   N)r+   LIMITER)rB   r   rC   zOptional[int]rA   r   )rJ   r   r=   bool)r=   r   )rT   r   r=   r   )r[   objectr=   rk   )r=   r   )r[   r6   r=   rk   )r   r    r!   r"   __doc__r2   r#   rF   classmethodrK   rO   rW   r\   r`   rd   rh   r$   r   r   r   r6   r6   ;   st     5I&& KT--&3-DG- B B9/(MDUr   r6   )	metaclassc                  "    \ rS rSrSr\S   rSrg)RateLimitItemPerYear   z!
per year rate limited resource.
r'   r   Nr   r    r!   r"   rm   
TIME_TYPESr3   r$   r   r   r   rq   rq      s     V$Kr   rq   c                  "    \ rS rSrSr\S   rSrg)RateLimitItemPerMonth   z"
per month rate limited resource.
r&   r   Nrs   r   r   r   rv   rv      s     W%Kr   rv   c                  "    \ rS rSrSr\S   rSrg)RateLimitItemPerDay   z 
per day rate limited resource.
r%   r   Nrs   r   r   r   ry   ry      s     U#Kr   ry   c                  "    \ rS rSrSr\S   rSrg)RateLimitItemPerHour   z!
per hour rate limited resource.
r(   r   Nrs   r   r   r   r|   r|      s     V$Kr   r|   c                  "    \ rS rSrSr\S   rSrg)RateLimitItemPerMinute   z#
per minute rate limited resource.
r*   r   Nrs   r   r   r   r   r           X&Kr   r   c                  "    \ rS rSrSr\S   rSrg)RateLimitItemPerSecond   z#
per second rate limited resource.
r,   r   Nrs   r   r   r   r   r      r   r   r   N)r   zUnion[bytes, str, int]r=   r   )rm   
__future__r   	functoolsr   typingr   r   r   r	   r
   r   r   limits.typingr   r   r   r   dictrt   r-   r#   typer/   r6   rq   rv   ry   r|   r   r   r   r   r   <module>r      s     " $ G G G (* 
 L%(
'
1	+V	4	Wf	%r8$q(#
 13- 2 ( PU/ PU PUf= M - = ] ] r   