+
    Q(i#                        R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ]'       d   ^ RIHt ] ! R R4      4       t] ! R	 R
4      4       tR R ltR R ltR R ltR R ltR R ltR R ltR# )uF  Version comparison utilities for component versioning.

This module provides utilities for comparing component versions. Versions are
strings that are first attempted to be parsed as PEP 440 versions (using the
`packaging` library), falling back to lexicographic string comparison.

Examples:
    - "1", "2", "10" → parsed as PEP 440, compared semantically (1 < 2 < 10)
    - "1.0", "2.0" → parsed as PEP 440
    - "v1.0" → 'v' prefix stripped, parsed as "1.0"
    - "2025-01-15" → not valid PEP 440, compared as strings
    - None → sorts lowest (unversioned components)
)annotations)	dataclass)total_ordering)TYPE_CHECKING)InvalidVersionVersion)FastMCPComponentc                  f    ] tR t^t$ RtRtR]R&   RtR]R&   RtR]R&   RR/R	 R
 llt	R R lt
RtR# )VersionSpeca~  Specification for filtering components by version.

Used by transforms and providers to filter components to a specific
version or version range. Unversioned components (version=None) always
match any spec.

Args:
    gte: If set, only versions >= this value match.
    lt: If set, only versions < this value match.
    eq: If set, only this exact version matches (gte/lt ignored).
N
str | Nonegtelteq
match_noneTc               $    V ^8  d   QhRRRRRR/# )   versionr   r   boolreturn )formats   "`/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/utilities/versions.py__annotate__VersionSpec.__annotate__-   s!      z $ $     c                  Vf   V# V P                   e   WP                   8H  # \        V4      pV P                  e   \        V P                  4      pW48  d   R# V P                  e   \        V P                  4      pW58  g   R# R# )a  Check if a version matches this spec.

Args:
    version: The version to check, or None for unversioned.
    match_none: Whether unversioned (None) components match. Defaults to True
        for backward compatibility with retrieval operations. Set to False
        when filtering (e.g., enable/disable) to exclude unversioned components
        from version-specific rules.

Returns:
    True if the version matches the spec.
FT)r   parse_version_keyr   r   )selfr   r   keygte_keylt_keys   &&$   r   matchesVersionSpec.matches-   ss     ?77gg%%(88'1G}77&tww/F<r   c                    V ^8  d   QhRRRR/# )r   otherzVersionSpec | Noner   r
   r   )r   s   "r   r   r   N   s      
  
1  
k  
r   c                   Vf   V # V P                   e0   VP                  V P                   4      '       d   V # \        RR7      # VP                   e0   V P                  VP                   4      '       d   V# \        RR7      # \        \        V P                  VP                  4      \        V P                  VP                  4      R7      # )a  Return a spec that satisfies both this spec and other.

Used by transforms to combine caller constraints with filter constraints.
For example, if a VersionFilter has lt="3.0" and caller requests eq="1.0",
the intersection validates "1.0" is in range and returns the exact spec.

Args:
    other: Another spec to intersect with, or None.

Returns:
    A VersionSpec that matches only versions satisfying both specs.
__impossible__)r   )r   r   )r   r!   r
   max_versionr   min_versionr   r   r$   s   &&r   	intersectVersionSpec.intersectN   s     =K77}}TWW%%"23388||EHH%%"233 DHHeii0477EHH-
 	
r   r   )__name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   r!   r*   __static_attributes__r   r   r   r
   r
      s>    
 CB
B
 B 
  
r   r
   c                  N    ] tR t^qtRtR
tR R ltR R ltR R ltR R	 lt	R
t
R# )
VersionKeya"  A comparable version key that handles None, PEP 440 versions, and strings.

Comparison order:
1. None (unversioned) sorts lowest
2. PEP 440 versions sort by semantic version order
3. Invalid versions (strings) sort lexicographically
4. When comparing PEP 440 vs string, PEP 440 comes first
c                    V ^8  d   QhRRRR/# )r   r   r   r   Noner   )r   s   "r   r   VersionKey.__annotate__~   s     ' '
 't 'r   c                	    Wn         VR J V n        RV n        R V n        VeE   VP	                  R4      '       d   VP                  R4      MTp \        V4      V n        RV n        R # R #   \         d    Yn         R # i ; i)NFvT)_raw_is_none
_is_pep440_parsed
startswithlstripr   r   )r   r   
normalizeds   && r   __init__VersionKey.__init__~   sy    	4-1070B0B30G0G,WJ'&z2"&  " '&'s   A( (A=<A=c                    V ^8  d   QhRRRR/# r   r$   objectr   r   r   )r   s   "r   r   r7      s      F t r   c                	   \        V\        4      '       g   \        # V P                  '       d   VP                  '       d   R # V P                  VP                  8w  d   R# V P                  '       d,   VP                  '       d   V P
                  VP
                  8H  # V P                  '       g,   VP                  '       g   V P
                  VP
                  8H  # R# )TF)
isinstancer4   NotImplementedr;   r<   r=   r)   s   &&r   __eq__VersionKey.__eq__   s    %,,!!===U^^^==ENN*???u///<<5==00u'7'7'7<<5==00r   c                    V ^8  d   QhRRRR/# rD   r   )r   s   "r   r   r7      s      F t r   c                	   \        V\        4      '       g   \        # V P                  '       d   VP                  '       d   R # V P                  '       d   R# VP                  '       d   R # V P                  '       dp   VP                  '       d^   \        V P
                  \        4      '       g   Q h\        VP
                  \        4      '       g   Q hV P
                  VP
                  8  # V P                  '       gp   VP                  '       g^   \        V P
                  \        4      '       g   Q h\        VP
                  \        4      '       g   Q hV P
                  VP
                  8  # V P                  # )FT)rG   r4   rH   r;   r<   r=   r   strr)   s   &&r   __lt__VersionKey.__lt__   s    %,,!!===U^^^===>>> ???u///dllG4444emmW5555<<%--//u'7'7'7dllC0000emmS1111<<%--// r   c                   V ^8  d   QhRR/# )r   r   rM   r   )r   s   "r   r   r7      s     , ,# ,r   c                	$    R V P                   : R2# )zVersionKey())r:   )r   s   &r   __repr__VersionKey.__repr__   s    TYYM++r   )r;   r<   r=   r:   N)r,   r-   r.   r/   r0   	__slots__rA   rI   rN   rS   r2   r   r   r   r4   r4   q   s'     >I' 4, ,r   r4   c                    V ^8  d   QhRRRR/# )r   r   r   r   r4   r   )r   s   "r   r   r      s     	 	z 	j 	r   c                    \        V 4      # )zParse a version string into a sortable key.

Args:
    version: The version string, or None for unversioned.

Returns:
    A VersionKey suitable for sorting.
)r4   )r   s   &r   r   r      s     gr   c                    V ^8  d   QhRRRR/# )r   	componentr   r   r4   r   )r   s   "r   r   r      s     0 0 0 0Z 0r   c                ,    \        V P                  4      # )ad  Get a sort key for a component based on its version.

Use with sorted() or max() to order components by version.

Args:
    component: The component to get a sort key for.

Returns:
    A sortable VersionKey.

Example:
    ```python
    tools = [tool_v1, tool_v2, tool_unversioned]
    highest = max(tools, key=version_sort_key)  # Returns tool_v2
    ```
)r   r   )rY   s   &r   version_sort_keyr[      s    " Y..//r   c               $    V ^8  d   QhRRRRRR/# )r   ar   br   intr   )r   s   "r   r   r      s!     - -
 -z -c -r   c                H    \        V 4      p\        V4      pW#8  W#8  ,
          # )an  Compare two version strings.

Args:
    a: First version string (or None).
    b: Second version string (or None).

Returns:
    -1 if a < b, 0 if a == b, 1 if a > b.

Example:
    ```python
    compare_versions("1.0", "2.0")  # Returns -1
    compare_versions("2.0", "1.0")  # Returns 1
    compare_versions(None, "1.0")   # Returns -1 (None < any version)
    ```
)r   )r]   r^   key_akey_bs   &&  r   compare_versionsrc      s'    " a Ea EMem,,r   c               $    V ^8  d   QhRRRRRR/# )r   r]   r   r^   r   r   r   )r   s   "r   r   r      s!     
& 
&* 
& 
& 
&r   c                    \        W4      ^ 8  # )zCheck if version a is greater than version b.

Args:
    a: First version string (or None).
    b: Second version string (or None).

Returns:
    True if a > b, False otherwise.
rc   r]   r^   s   &&r   is_version_greaterrh      s     A!A%%r   c               $    V ^8  d   QhRRRRRR/# r   r]   r   r^   r   r   )r   s   "r   r   r      !     3 3: 3* 3 3r   c                B    V f   V# Vf   V # \        W4      ^ 8  d   V # T# )zReturn the greater of two versions.

Args:
    a: First version string (or None).
    b: Second version string (or None).

Returns:
    The greater version, or None if both are None.
rf   rg   s   &&r   r'   r'      /     	yy &!+122r   c               $    V ^8  d   QhRRRRRR/# rj   r   )r   s   "r   r   r     rk   r   c                B    V f   V# Vf   V # \        W4      ^ 8:  d   V # T# )zReturn the lesser of two versions.

Args:
    a: First version string (or None).
    b: Second version string (or None).

Returns:
    The lesser version, or None if both are None.
rf   rg   s   &&r   r(   r(     rm   r   N)r0   
__future__r   dataclassesr   	functoolsr   typingr   packaging.versionr   r   fastmcp.utilities.componentsr   r
   r4   r   r[   rc   rh   r'   r(   r   r   r   <module>rv      sy    # ! $   5= R
 R
 R
j F, F, F,R	0(-,
&3"3r   