
    ցj>                    j   % S r SSKJr  SSKrSSKrSSKrSSKJrJrJrJ	r	J
r
Jr  SSKJrJrJrJrJrJrJrJrJr  SSKJr  SSKJr  \(       a7  SSKrSS	KJrJrJr  \R>                  S
:  a  SSKJ r   OSSK!J r   SSK"J#r#  SSKJ$r$  / SQr%S$S jr&S%S jr'S&S jr(\
" S5      r)\\\*4   r+\
" S\+S9r,\RZ                  \R\                  \R^                  \R`                  S.r1S\2S'   S'S jr3 " S S\45      r5 " S S\Rl                  S9r7 " S S\75      r8        S(S  jr9 " S! S"\75      r:      S)S# jr;g)*z
.. testsetup::

    from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
    from packaging.version import Version
    )annotationsN)TYPE_CHECKINGAnyCallableFinalTypeVarUnion   )	
FULL_RANGEbounds_for_speccoerce_versionfilter_by_rangesintersect_specifier_boundsmatches_bounds_onlyranges_are_prerelease_onlyresolve_prereleasestrim_release)canonicalize_version)Version)IterableIteratorSequence)   
   )	TypeGuard)ranges)Interval)BaseSpecifierInvalidSpecifier	SpecifierSpecifierSetc                     [         $ N)__all__     N/mnt/workspace/venv-train/lib/python3.13/site-packages/packaging/specifiers.py__dir__r(   <   s    Nr&   c                   [        U [        5      =(       aB    [        U 5      S:H  =(       a-    [        U S   [        5      =(       a    [        U S   [        5      $ )N   r   r
   )
isinstancetuplelenstr)specs    r'   _validate_specr0   @   sI    4 	%IN	%tAw$	% tAw$	r&   c               8    U S L =(       d    [        U [        5      $ r#   )r+   bool)pres    r'   _validate_prer4   I   s    $;/*S$//r&   TUnparsedVersionVar)bound)>=<===!=z-dict[str, Callable[[Version, Version], bool]]_DIRECT_COMPARE_OPSr    c                   U R                   u  p#UR                  S5      (       d  UR                  b  g[        R	                  U5      nUb  U" XR                  U5      5      $ US;   af  U R                  U5      nUR                  UR                  :w  d,  [        UR                  5      [        UR                  5      :w  a  US:X  a  X:  $ X:  $ gg)a  Match ``parsed`` against ``specifier`` without building a range.

Handles ``>=``, ``<=``, ``==``, ``!=``, ``<``, ``>`` when the spec is
not a wildcard and ``parsed`` has no local. Returns ``None`` when the
range path must be used. Pre-release policy is left to the caller.
.*N)<>r?   )	_specendswithlocalr<   get_require_spec_versionepochr   release)	specifierparsedop_strver_strdirect_comparespec_vs         r'   _fast_matchrN   ]   s      ooOF!9(,,V4N!f&E&Eg&NOO009 <<6<<'<+G<NNL
 ,
 '-m6?HHr&   c                      \ rS rSrSrSrg)r   z   z
Raised when attempting to create a :class:`Specifier` with a specifier
string that is invalid.

>>> Specifier("lolwat")
Traceback (most recent call last):
    ...
packaging.specifiers.InvalidSpecifier: Invalid specifier: 'lolwat'
r%   N)__name__
__module____qualname____firstlineno____doc____static_attributes__r%   r&   r'   r   r   z   s    r&   r   c                     \ rS rSrSrSrSr\SS j5       r\	R                  SS j5       r\	R                  SS j5       r\	R                  SS j5       r\\	R                  SS	 j5       5       r\R                  SS
 j5       r\	R                  SSS jj5       r\R$                    S       SS jj5       r\R$                    S       SS jj5       r\	R                    S       SS jj5       rSrg)r      zG
Abstract base class for :class:`Specifier` and :class:`SpecifierSet`.
r%   )_strc                    [        U 5      $ )z Internal property for match_argsr.   selfs    r'   rY   BaseSpecifier._str   s     4yr&   c                    g)zv
Returns the str representation of this Specifier-like object. This
should be representative of the Specifier itself.
Nr%   r\   s    r'   __str__BaseSpecifier.__str__       r&   c                    g)z6
Returns a hash value for this Specifier-like object.
Nr%   r\   s    r'   __hash__BaseSpecifier.__hash__   rb   r&   c                    g)z
Returns a boolean representing whether or not the two Specifier-like
objects are equal.

:param other: The other object to check against.
Nr%   r]   others     r'   __eq__BaseSpecifier.__eq__   rb   r&   c                    g)zWhether or not pre-releases as a whole are allowed.

This can be set to either ``True`` or ``False`` to explicitly enable or disable
prereleases or it can be set to ``None`` (the default) to use default semantics.
Nr%   r\   s    r'   prereleasesBaseSpecifier.prereleases   rb   r&   c                    g)zASetter for :attr:`prereleases`.

:param value: The value to set.
Nr%   r]   values     r'   rl   rm      rb   r&   Nc                    g)zB
Determines if the given item is contained within this specifier.
Nr%   )r]   itemrl   s      r'   containsBaseSpecifier.contains   rb   r&   c                    g r#   r%   r]   iterablerl   keys       r'   filterBaseSpecifier.filter        (+r&   c                    g r#   r%   rv   s       r'   ry   rz           r&   c                    g)z}
Takes an iterable of items and filters them so that only items which
are contained within this specifier are allowed in it.
Nr%   rv   s       r'   ry   rz      rb   r&   returnr.   r   intrh   objectr   r2   r   bool | None)rp   r2   r   Noner#   )rr   r.   rl   r   r   r2   N.rw   zIterable[UnparsedVersionVar]rl   r   rx   r   r   zIterator[UnparsedVersionVar]rw   zIterable[T]rl   r   rx   zCallable[[T], UnparsedVersion]r   zIterator[T]NNrw   Iterable[Any]rl   r   rx   'Callable[[Any], UnparsedVersion] | Noner   Iterator[Any])rQ   rR   rS   rT   rU   	__slots____match_args__propertyrY   abcabstractmethodr`   rd   ri   rl   setterrs   typingoverloadry   rV   r%   r&   r'   r   r      s    IN  	  	 
 	       	 
 __ $(	+.+ !+ 	+
 
&+ + __ $(.1	 ! ,	
 
  	 $(7;			 !	 5		
 
	 	r&   r   )	metaclassc            	      6   \ rS rSr% SrSrSr\R                  " S\-   S-   \R                  \R                  -  5      rSSSS	S
SSSS.rS\S'   S&S'S jjrS(S jrS)S jrS*S jr\S+S j5       r\R(                  S,S j5       rS-S jrS.S jr\S/S j5       r\S/S j5       rS/S jrS/S jr\S0S j5       rS1S jrS2S  jrS3S! jrS4S5S" jjr\ RB                    S6       S7S# jj5       r"\ RB                    S6       S8S$ jj5       r"  S9       S:S% jjr"Sr#g);r       a  This class abstracts handling of version specifiers.

.. tip::

    It is generally not required to instantiate this manually. You should instead
    prefer to work with :class:`SpecifierSet` instead, which can parse
    comma-separated version specifiers (which is what package metadata contains).

Instances are safe to serialize with :mod:`pickle`. They use a stable
format so the same pickle can be loaded in future packaging releases.

.. versionchanged:: 26.2

    Added a stable pickle format. Pickles created with packaging 26.2+ can
    be unpickled with future releases.  Backward compatibility with pickles
    from packaging < 26.2 is supported but may be removed in a future
    release.
)_prereleases_rangesrA   _spec_versiona  
        (?:
            (?:
                # The identity operators allow for an escape hatch that will
                # do an exact string match of the version you wish to install.
                # This will not be parsed by PEP 440 and we cannot determine
                # any semantic meaning from it. This operator is discouraged
                # but included entirely as an escape hatch.
                ===  # Only match for the identity operator
                \s*
                [^\s;)]*  # The arbitrary version can be just about anything,
                          # we match everything except for whitespace, a
                          # semi-colon for marker support, and a closing paren
                          # since versions can be enclosed in them.
            )
            |
            (?:
                # The (non)equality operators allow for wild card and local
                # versions to be specified so we have to define these two
                # operators separately to enable that.
                (?:==|!=)            # Only match for equals and not equals

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release

                # You cannot use a wild card and a pre-release, post-release, a dev or
                # local version together so group them with a | and make them optional.
                (?:
                    \.\*  # Wild card syntax of .*
                    |
                    (?a:                                  # pre release
                        [-_\.]?
                        (alpha|beta|preview|pre|a|b|c|rc)
                        [-_\.]?
                        [0-9]*
                    )?
                    (?a:                                  # post release
                        (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                    )?
                    (?a:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
                    (?a:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local
                )?
            )
            |
            (?:
                # The compatible operator requires at least two digits in the
                # release segment.
                (?:~=)               # Only match for the compatible operator

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)+   # release  (We have a + instead of a *)
                (?:                   # pre release
                    [-_\.]?
                    (alpha|beta|preview|pre|a|b|c|rc)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
            |
            (?:
                # All other operators only allow a sub set of what the
                # (non)equality operators do. Specifically they do not allow
                # local versions to be specified nor do they allow the prefix
                # matching wild cards.
                (?:<=|>=|<|>)

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?a:                   # pre release
                    [-_\.]?
                    (alpha|beta|preview|pre|a|b|c|rc)
                    [-_\.]?
                    [0-9]*
                )?
                (?a:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?a:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
        )
        z\s*
compatibleequal	not_equalless_than_equalgreater_than_equal	less_thangreater_than	arbitrary)~=r:   r;   r9   r8   r?   r@   ===r   
_operatorsNc                   U R                   R                  U5      (       d  [        SU< 35      eUR                  5       nUR	                  S5      (       a  USS USS R                  5       pCOEUR	                  S5      (       a  USS USS R                  5       pCOUSS USS R                  5       pCX44U l        X l        SU l        SU l        g)a  Initialize a Specifier instance.

:param spec:
    The string representation of a specifier which will be parsed and
    normalized before use.
:param prereleases:
    This tells the specifier if it should accept prerelease versions if
    applicable or not. The default of ``None`` will autodetect it from the
    given specifiers.
:raises InvalidSpecifier:
    If the given specifier is invalid (i.e. bad syntax).
zInvalid specifier: r   Nr   )r   r:   r;   r9   r8   r*   r
   )	_regex	fullmatchr   strip
startswithrA   r   r   r   )r]   r/   rl   operatorversions        r'   __init__Specifier.__init__c  s     {{$$T**"%8#ABBzz|??5!! $Ra$qr(..*:g__;<< $Ra$qr(..*:g $Ra$qr(..*:g'/&9
 ( :> 37r&   c                    U R                   b"  U R                   S   U:X  a  U R                   S   $ [        U5      nUc  gX4U l         U$ )zDOne element cache, as only one spec Version is needed per Specifier.Nr   r
   )r   r   )r]   r   version_specifiers      r'   _get_spec_versionSpecifier._get_spec_version  sV    )d.@.@.Cw.N%%a((*73$%9  r&   c                2    U R                  U5      nUc   eU$ )zGet spec version, asserting it's valid (not for === operator).

This method should only be called for operators where version
strings are guaranteed to be valid PEP 440 versions (not ===).
)r   )r]   r   spec_versions      r'   rE   Specifier._require_spec_version  s&     --g6'''r&   c                    U R                   b  U R                   $ U R                  nU R                  nUS:X  a  [        nO,U R	                  UR                  S5      5      n[        XU5      nX0l         U$ )zConvert this specifier to sorted, non-overlapping version ranges.

Each standard operator maps to one or two ranges.  ``===`` is
modeled as full range (actual check done separately).  Cached.
r   r>   )r   r   r   r   rE   removesuffixr   )r]   oprK   resultr   s        r'   
_to_rangesSpecifier._to_ranges  sg     <<#<<]],,;)3F001E1Ed1KLG$R':Fr&   c                    U R                   b  U R                   $ U R                  u  pUS:X  a  gUS:X  a  UR                  S5      (       a  gU R                  U5      nUc  g UR                  $ )Nr;   Fr:   r>   )r   rA   rB   r   is_prerelease)r]   r   version_strr   s       r'   rl   Specifier.prereleases  sz     ($$$ !%

t t 4 4T : : ((5? $$$r&   c                    Xl         g r#   )r   ro   s     r'   rl   r     s    !r&   c                2    U R                   U R                  4$ r#   )rA   r   r\   s    r'   __getstate__Specifier.__getstate__  s     

D--..r&   c                   S U l         S U l        [        U[        5      (       a  [	        U5      S:X  a1  Uu  p#[        U5      (       a  [        U5      (       a  X l        X0l        g [	        U5      S:X  al  [        US   [        5      (       aT  Uu  pEUR                  S5      nUR                  SS5      n[        U5      (       a  [        U5      (       a  X l        X0l        g [        U[        5      (       aP  UR                  S5      nUR                  SS5      n[        U5      (       a  [        U5      (       a  X l        X0l        g [        SU< 35      e)Nr*   r
   rA   r   invalidzCannot restore Specifier from )r   r   r+   r,   r-   r0   r4   rA   r   dictrD   	TypeError)r]   stater/   rl   _	slot_dicts         r'   __setstate__Specifier.__setstate__  s   !eU##5zQ$)!!$''M+,F,F!%J(3%5zQ:eAh#=#=$ }}W-'mmNIF!$''M+,F,F!%J(3%eT""99W%D))NI>Kd##k(B(B!
$/!8	BCCr&   c                     U R                   S   $ )zHThe operator of this specifier.

>>> Specifier("==1.2.3").operator
'=='
r   rA   r\   s    r'   r   Specifier.operator       zz!}r&   c                     U R                   S   $ )zIThe version of this specifier.

>>> Specifier("==1.2.3").version
'1.2.3'
r
   r   r\   s    r'   r   Specifier.version  r   r&   c                    U R                   b  SU R                  < 3OSnSU R                  R                   S[	        U 5      < U S3$ )a  A representation of the Specifier that shows all internal state.

>>> Specifier('>=1.0.0')
<Specifier('>=1.0.0')>
>>> Specifier('>=1.0.0', prereleases=False)
<Specifier('>=1.0.0', prereleases=False)>
>>> Specifier('>=1.0.0', prereleases=True)
<Specifier('>=1.0.0', prereleases=True)>
, prereleases= r?   ()>r   rl   	__class__rQ   r.   r]   r3   s     r'   __repr__Specifier.__repr__
  sU       , T--01 	 4>>**+1SYM#bAAr&   c                4    SR                   " U R                  6 $ )zA string representation of the Specifier that can be round-tripped.

>>> str(Specifier('>=1.0.0'))
'>=1.0.0'
>>> str(Specifier('>=1.0.0', prereleases=False))
'>=1.0.0'
z{}{})formatrA   r\   s    r'   r`   Specifier.__str__  s     }}djj))r&   c                    U R                   u  pUS:X  d  UR                  S5      (       a  X4$ U R                  U5      n[        X1S:g  S9nX4$ )Nr   r>   r   )strip_trailing_zero)rA   rB   rE   r   )r]   r   r   r   canonical_versions        r'   _canonical_specSpecifier._canonical_spec&  s]     JJu 0 0 6 6$$11':04/?
 **r&   c                ,    [        U R                  5      $ r#   )hashr   r\   s    r'   rd   Specifier.__hash__4  s    D(())r&   c                   [        U[        5      (       a   U R                  [        U5      5      nO [        XR                  5      (       d  [        $ U R
                  UR
                  :H  $ ! [         a	    [        s $ f = f)a  Whether or not the two Specifier-like objects are equal.

:param other: The other object to check against.

The value of :attr:`prereleases` is ignored.

>>> Specifier("==1.2.3") == Specifier("== 1.2.3.0")
True
>>> (Specifier("==1.2.3", prereleases=False) ==
...  Specifier("==1.2.3", prereleases=True))
True
>>> Specifier("==1.2.3") == "==1.2.3"
True
>>> Specifier("==1.2.3") == Specifier("==1.2.4")
False
>>> Specifier("==1.2.3") == Specifier("~=1.2.3")
False
)r+   r.   r   r   NotImplementedr   rg   s     r'   ri   Specifier.__eq__7  sm    & eS!!&s5z2 E>>22!!##u'<'<<< $ &%%&s   A+ +A>=A>c                $    U R                  U5      $ )a  Return whether or not the item is contained in this specifier.

:param item: The item to check for.

This is used for the ``in`` operator and behaves the same as
:meth:`contains` with no ``prereleases`` argument passed.

>>> "1.2.3" in Specifier(">=1.2.3")
True
>>> Version("1.2.3") in Specifier(">=1.2.3")
True
>>> "1.0.0" in Specifier(">=1.2.3")
False
>>> "1.3.0a1" in Specifier(">=1.2.3")
True
>>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
True
rs   r]   rr   s     r'   __contains__Specifier.__contains__T      & }}T""r&   c           	     T   U R                   S   S:X  a#  [        [        U R                  U/US95      5      $ [	        U5      nUc  gUc   [        U R                  U R                  5      nUSL a  UR                  (       a  g[        X5      nUb  U$ [        U R                  5       U5      $ )aW  Return whether or not the item is contained in this specifier.

:param item:
    The item to check for, which can be a version string or a
    :class:`~packaging.version.Version` instance.
:param prereleases:
    Whether or not to match prereleases with this Specifier. If set to
    ``None`` (the default), it will follow the recommendation from
    :pep:`440` and match prereleases, as there are no other versions.

>>> Specifier(">=1.2.3").contains("1.2.3")
True
>>> Specifier(">=1.2.3").contains(Version("1.2.3"))
True
>>> Specifier(">=1.2.3").contains("1.0.0")
False
>>> Specifier(">=1.2.3").contains("1.3.0a1")
True
>>> Specifier(">=1.2.3", prereleases=False).contains("1.3.0a1")
False
>>> Specifier(">=1.2.3").contains("1.3.0a1")
True

.. versionchanged:: 26.0

    With ``prereleases=None``, a prerelease now matches. A single
    version has no alternatives, so the :pep:`440` rule to accept
    prereleases when nothing else satisfies the specifier applies.
    Earlier versions rejected it. An unparsable version now returns
    ``False`` instead of raising :exc:`~packaging.version.InvalidVersion`.
r   r   rl   F)rA   r2   listry   r   r   r   rl   r   rN   r   r   )r]   rr   rl   rI   matchs        r'   rs   Specifier.containsi  s    D ::a=E!T[[$[[IJKK%>-d.?.?AQAQRK%F$8$8 D)L"4??#4f==r&   c                    g r#   r%   rv   s       r'   ry   Specifier.filter  r{   r&   c                    g r#   r%   rv   s       r'   ry   r     r}   r&   c                  ^^ Uc   [        U R                  U R                  5      nU R                  S:X  a4  U R                  R                  5       mUU4S jU 5       n[        UTU5      $ [        U R                  5       UTU5      $ )a  Filter items in the given iterable, that match the specifier.

:param iterable:
    An iterable that can contain version strings and
    :class:`~packaging.version.Version` instances. The items in the
    iterable will be filtered according to the specifier.
:param prereleases:
    Whether or not to allow prereleases in the returned iterator. If set to
    ``None`` (the default), it will follow the recommendation from :pep:`440`
    and match prereleases if there are no other versions.
:param key:
    A callable that takes a single argument (an item from the iterable) and
    returns a version string or :class:`~packaging.version.Version`
    instance to be used for filtering.

>>> list(Specifier(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
['1.3']
>>> list(Specifier(">=1.2.3").filter(["1.2", "1.2.3", "1.3", Version("1.4")]))
['1.2.3', '1.3', <Version('1.4')>]
>>> list(Specifier(">=1.2.3").filter(["1.2", "1.5a1"]))
['1.5a1']
>>> list(Specifier(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
['1.3', '1.5a1']
>>> list(Specifier(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
['1.3', '1.5a1']
>>> list(Specifier(">=1.2.3").filter(
... [{"ver": "1.2"}, {"ver": "1.3"}],
... key=lambda x: x["ver"]))
[{'ver': '1.3'}]

.. versionchanged:: 26.1

    Added the ``key`` parameter.
r   c              3  |   >#    U  H1  n[        Tc  UOT" U5      5      R                  5       T:X  d  M-  Uv   M3     g 7fr#   )r.   lower).0rr   rx   
spec_lowers     r'   	<genexpr>#Specifier.filter.<locals>.<genexpr>  s:      $Ds{tD	:@@BjP $s   ,<	<)	r   r   rl   r   r   r   _apply_prereleases_filterr   r   )r]   rw   rl   rx   matchesr   s      ` @r'   ry   r     sz    P -d.?.?AQAQRK==E!++-J$G
 -Wc;GG 18S+NNr&   r   N)r/   r.   rl   r   r   r   )r   r.   r   zVersion | None)r   r.   r   r   r   zSequence[Interval]r   rp   r   r   r   )r   z#tuple[tuple[str, str], bool | None]r   r   r   r   r   )r   ztuple[str, str]r   r   )rr   zstr | Versionr   r2   r#   )rr   UnparsedVersionrl   r   r   r2   r   r   r   r   r   )$rQ   rR   rS   rT   rU   r   _specifier_regex_strrecompileVERBOSE
IGNORECASEr   r   __annotations__r   r   rE   r   r   rl   r   r   r   r   r   r   r`   r   rd   ri   r   rs   r   r   ry   rV   r%   r&   r'   r    r       s   &IZx ZZ%%.

R]]0JF "	J 	!7F
!* % %6 " "/DB    B$* + +*=:#*6>p __ $(	+.+ !+ 	+
 
&+ + __ $(.1	 ! ,	
 
  $(7;	4O4O !4O 5	4O
 
4O 4Or&   c                b   ^^ Uc  [        U T5      $ U(       a  [        U 5      $ UU4S jU  5       $ )zApply ``prereleases=`` handling to an already-matched iterable.

``None`` means PEP 440 default (buffer pre-releases until a final
appears); ``True`` yields everything; ``False`` drops pre-releases.
c              3     >#    U  H3  n[        Tc  UOT" U5      5      =mb  TR                  (       a  M/  Uv   M5     g 7fr#   )r   r   )r   rr   rx   rI   s     r'   r  ,_apply_prereleases_filter.<locals>.<genexpr>  s=      D$S[Tc$iHHFQ## 	s   .>	>)_pep440_filter_prereleasesiter)r  rx   rl   rI   s    ` @r'   r  r    s7     )'377G} r&   c                     \ rS rSrSrSr  S     S S jjrS!S jr\S"S j5       r	\	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)S j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.S jrS/S jrS/S jrS/S jrS0S jr  S1       S2S jjr\R>                    S3       S4S jj5       r \R>                    S3       S5S jj5       r   S1       S6S jjr Sr!g)7r!   i  aU  This class abstracts handling of a set of version specifiers.

It can be passed a single specifier (``>=3.0``), a comma-separated list of
specifiers (``>=3.0,!=3.1``), or no specifier at all.

Instances are safe to serialize with :mod:`pickle`. They use a stable
format so the same pickle can be loaded in future packaging
releases.

.. versionchanged:: 26.2

    Added a stable pickle format. Pickles created with
    packaging 26.2+ can be unpickled with future releases.
    Backward compatibility with pickles from
    packaging < 26.2 is supported but may be removed in a future
    release.
)_canonicalized_has_arbitrary_is_unsatisfiabler   r   _specsNc                   [        U[        5      (       an  UR                  S5       Vs/ s H)  o3R                  5       (       d  M  UR                  5       PM+     nn[	        [        [        U5      5      U l        SU;   U l        O1[	        U5      U l        [        S U R                   5       5      U l        [        U R                  5      S:*  U l        SU l        SU l        X l        gs  snf )aL  Initialize a SpecifierSet instance.

:param specifiers:
    The string representation of a specifier or a comma-separated list of
    specifiers which will be parsed and normalized before use.
    May also be an iterable of ``Specifier`` instances, which will be used
    as is.
:param prereleases:
    This tells the SpecifierSet if it should accept prerelease versions if
    applicable or not. The default of ``None`` will autodetect it from the
    given specifiers.

:raises InvalidSpecifier:
    If the given ``specifiers`` are not parseable than this exception will be
    raised.
,r   c              3  >   #    U  H  nS [        U5      ;   v   M     g7fr   Nr[   r   ss     r'   r  (SpecifierSet.__init__.<locals>.<genexpr><  s     %K{!es1vo{   r
   N)r+   r.   splitr   r,   mapr    r  r  anyr-   r  r  r   r   )r]   
specifiersrl   r  split_specifierss        r'   r   SpecifierSet.__init__  s    , j#&& 4>3C3CC3HV3HaGGI		3HV16s9FV7W1XDK"':"5D
+DK #&%Kt{{%K"KD!$++.!3.226 (#  Ws   C'C'c           	         U R                   (       d@  [        [        R                  [	        U R
                  [        S95      5      U l        SU l         U R
                  $ )zBDeduplicate, sort, and cache specs for order-sensitive operations.rx   T)r  r,   r   fromkeyssortedr  r.   r\   s    r'   _canonical_specsSpecifierSet._canonical_specsF  s=    ""fT[[c.J KLDK"&D{{r&   c                    U R                   b  U R                   $ U R                  (       d  g [        S U R                   5       5      (       a  gg )Nc              3  8   #    U  H  oR                   v   M     g 7fr#   r   r  s     r'   r  +SpecifierSet.prereleases.<locals>.<genexpr>\  s     2k}}k   T)r   r  r$  r\   s    r'   rl   SpecifierSet.prereleasesM  sE     ($$$
 {{ 2dkk222r&   c                    Xl         S U l        g r#   )r   r  ro   s     r'   rl   r2  a  s    !!%r&   c                2    U R                   U R                  4$ r#   )r  r   r\   s    r'   r   SpecifierSet.__getstate__f  s     T..//r&   c                L   S U l         S U l        [        U[        5      (       Ga  [	        U5      S:X  aw  Uu  p#[        U[        5      (       a^  [        S U 5       5      (       aG  [        U5      (       a7  X l        X0l        [	        U5      S:*  U l	        [        S U 5       5      U l        g [	        U5      S:X  a  [        US   [        5      (       a  Uu  pEUR                  SS5      nUR                  S5      n[        U[        5      (       a  [        [        U[         S95      n[        U[        5      (       ar  [        S	 U 5       5      (       a[  [        U5      (       aK  X l        X0l        [	        U R                  5      S:*  U l	        [        S
 U R                   5       5      U l        g [        U[        5      (       a  UR                  SS5      nUR                  S5      n[        U[        5      (       a  [        [        U[         S95      n[        U[        5      (       ar  [        S U 5       5      (       a[  [        U5      (       aK  X l        X0l        [	        U R                  5      S:*  U l	        [        S U R                   5       5      U l        g [#        SU< 35      e)Nr*   c              3  B   #    U  H  n[        U[        5      v   M     g 7fr#   r+   r    r  s     r'   r  ,SpecifierSet.__setstate__.<locals>.<genexpr>w       DeJq)44e   r
   c              3  >   #    U  H  nS [        U5      ;   v   M     g7fr  r[   r  s     r'   r  r9  }  s     -Mu!es1vour!  r  r%   r   r)  c              3  B   #    U  H  n[        U[        5      v   M     g 7fr#   r8  r  s     r'   r  r9    r:  r;  c              3  >   #    U  H  nS [        U5      ;   v   M     g7fr  r[   r  s     r'   r  r9    s     -S{!es1vo{r!  c              3  B   #    U  H  n[        U[        5      v   M     g 7fr#   r8  r  s     r'   r  r9    s     @%Q
1i00%r;  c              3  >   #    U  H  nS [        U5      ;   v   M     g7fr  r[   r  s     r'   r  r9    s     )O;a%3q6/;r!  z!Cannot restore SpecifierSet from )r   r  r+   r,   r-   allr4   r  r   r  r$  r  r   rD   	frozensetr+  r.   r   )r]   r   specsrl   r   r   s         r'   r   SpecifierSet.__setstate__l  s   !%eU##5zQ%*"ue,,DeDDD%k22"'K(3%*-e*/D'*--Mu-M*MD'5zQ:eAh#=#=$!h3'mmN;eY//!&C"89Eue,,DeDDD%k22"'K(3%*-dkk*:a*?D'*--St{{-S*SD'eT""IIh+E))N3K%++fU455%((@%@@@!+..#$/!&)$++&6!&;#&))O4;;)O&O#;E9EFFr&   c                    U R                   b  SU R                  < 3OSnSU R                  R                   S[	        U 5      < U S3$ )a  A representation of the specifier set that shows all internal state.

Note that the ordering of the individual specifiers within the set may not
match the input string.

>>> SpecifierSet('>=1.0.0,!=2.0.0')
<SpecifierSet('!=2.0.0,>=1.0.0')>
>>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=False)
<SpecifierSet('!=2.0.0,>=1.0.0', prereleases=False)>
>>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=True)
<SpecifierSet('!=2.0.0,>=1.0.0', prereleases=True)>
r   r   r?   r   r   r   r   s     r'   r   SpecifierSet.__repr__  sU       , T--01 	 4>>**+1SYM#bAAr&   c                N    SR                  S U R                  5        5       5      $ )a6  A string representation of the specifier set that can be round-tripped.

Note that the ordering of the individual specifiers within the set may not
match the input string.

>>> str(SpecifierSet(">=1.0.0,!=1.0.1"))
'!=1.0.1,>=1.0.0'
>>> str(SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False))
'!=1.0.1,>=1.0.0'
r  c              3  8   #    U  H  n[        U5      v   M     g 7fr#   r[   r  s     r'   r  'SpecifierSet.__str__.<locals>.<genexpr>  s     @(?1A(?r1  )joinr,  r\   s    r'   r`   SpecifierSet.__str__  s"     xx@(=(=(?@@@r&   c                4    [        U R                  5       5      $ r#   )r   r,  r\   s    r'   rd   SpecifierSet.__hash__  s    D))+,,r&   c                   [        U[        5      (       a  [        U5      nO[        U[        5      (       d  [        $ [        5       nU R                  UR                  -   Ul        [        UR                  5      S:*  Ul        U R                  =(       d    UR                  Ul        U R                  b  U R                  UR                  :X  a  UR                  Ul        U$ UR                  c  U R                  Ul        U$ [        S5      e)aR  Return a SpecifierSet which is a combination of the two sets.

:param other: The other object to combine with.

>>> SpecifierSet(">=1.0.0,!=1.0.1") & '<=2.0.0,!=2.0.1'
<SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
>>> SpecifierSet(">=1.0.0,!=1.0.1") & SpecifierSet('<=2.0.0,!=2.0.1')
<SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
r
   zFCannot combine SpecifierSets with True and False prerelease overrides.)
r+   r.   r!   r   r  r-   r  r  r   
ValueError)r]   rh   rH   s      r'   __and__SpecifierSet.__and__  s     eS!! 'EE<00!! N	;;5	#&y'7'7#8A#=	 #'#6#6#N%:N:N	  $(9(9U=O=O(O%*%7%7I"  '%)%6%6I" 	 X r&   c                    [        U[        [        45      (       a  [        [        U5      5      nO[        U[        5      (       d  [        $ U R                  5       UR                  5       :H  $ )a1  Whether or not the two SpecifierSet-like objects are equal.

:param other: The other object to check against.

The value of :attr:`prereleases` is ignored.

>>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.1")
True
>>> (SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False) ==
...  SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True))
True
>>> SpecifierSet(">=1.0.0,!=1.0.1") == ">=1.0.0,!=1.0.1"
True
>>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0")
False
>>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.2")
False
)r+   r.   r    r!   r   r,  rg   s     r'   ri   SpecifierSet.__eq__  sT    & ec9-.. U,EE<00!!$$&%*@*@*BBBr&   c                ,    [        U R                  5      $ )z7Returns the number of specifiers in this specifier set.)r-   r  r\   s    r'   __len__SpecifierSet.__len__  s    4;;r&   c                ,    [        U R                  5      $ )z
Returns an iterator over all the underlying :class:`Specifier` instances
in this specifier set.

>>> sorted(SpecifierSet(">=1.0.0,!=1.0.1"), key=str)
[<Specifier('!=1.0.1')>, <Specifier('>=1.0.0')>]
)r  r  r\   s    r'   __iter__SpecifierSet.__iter__  s     DKK  r&   c                    U R                   b  U R                   $ [        S U R                   5       5      U l         U R                   $ )zIntersect all specifiers into a single sequence of version ranges.

Empty when unsatisfiable. Callers must ensure ``self._specs``
is non-empty.
c              3  @   #    U  H  oR                  5       v   M     g 7fr#   )r   r  s     r'   r  +SpecifierSet._get_ranges.<locals>.<genexpr>  s     1V+Q,,..+s   )r   r   r  r\   s    r'   _get_rangesSpecifierSet._get_ranges  s8     <<#<<11V$++1VV||r&   c                   U R                   nUb  U$ U R                  (       d  SU l         gU R                  5       (       + nU(       d  U R                  5       nU(       d(  U R                  SL a  [        U R                  5       5      nX l         U$ )an  Check whether this specifier set can never be satisfied.

Returns True if no version can satisfy all specifiers simultaneously.

>>> SpecifierSet(">=2.0,<1.0").is_unsatisfiable()
True
>>> SpecifierSet(">=1.0,<2.0").is_unsatisfiable()
False
>>> SpecifierSet("").is_unsatisfiable()
False
>>> SpecifierSet("==1.0,!=1.0").is_unsatisfiable()
True

.. versionadded:: 26.1
F)r  r  r]  _check_arbitrary_unsatisfiablerl   r   )r]   cachedr   s      r'   is_unsatisfiableSpecifierSet.is_unsatisfiable  s|      ''M{{%*D"%%''88:F$**e3/0@0@0BCF!'r&   c                  ^^ U R                    Vs/ s H  oR                  S:X  d  M  UPM     nnU(       d  gUS   R                  R                  5       m[	        U4S jUSS  5       5      (       a  g[        US   R                  5      mU R                  SL a  Tb  TR                  (       a  gU R                    Vs/ s H  oR                  S:w  d  M  UPM     nnU(       d  gTc  g[        U4S jU 5       5      (       + $ s  snf s  snf )	zCheck === (arbitrary equality) specs for unsatisfiability.

=== uses case-insensitive string comparison, so the only candidate
that can match ``===V`` is the literal string V.  This method
checks whether that candidate is excluded by other specifiers.
r   Fr   c              3  \   >#    U  H!  oR                   R                  5       T:g  v   M#     g 7fr#   )r   r   )r   r  firsts     r'   r  >SpecifierSet._check_arbitrary_unsatisfiable.<locals>.<genexpr>N  s     A=ayy E)=s   ),r
   NTc              3  D   >#    U  H  oR                  T5      v   M     g 7fr#   r   )r   r  	candidates     r'   r  rg  f  s     ?hzz),,hs    )	r  r   r   r   r$  r   rl   r   rA  )r]   r  r   standardri  rf  s       @@r'   r`  +SpecifierSet._check_arbitrary_unsatisfiableA  s     !%C1zzU/BQ	C !$$**,A9QR=AAA #9Q<#7#78	
 %%''#{{B{!jjE.AA{B?h????= D, Cs   DD=DDc                0    SSK Jn  UR                  U 5      $ )a3  Return the :class:`~packaging.ranges.VersionRange` this set accepts.

An empty set yields the full range; an unsatisfiable set yields the
empty range. ``===`` specifiers contribute literal-string admission.

>>> SpecifierSet(">=1.0,<2.0").to_range()
<VersionRange '[1.0, 2.0.dev0)'>

.. versionadded:: 26.3
r
   )VersionRange)r   rm  _from_specifier_set)r]   rm  s     r'   to_rangeSpecifierSet.to_rangeh  s     	)//55r&   c                    [        U[        5      (       d  [        S5      eU R                  (       d  UR                  (       a  [	        S5      eg )Nzexpected a SpecifierSetz+set relations do not support === specifiers)r+   r!   r   r  rO  rg   s     r'   _check_relation_operand$SpecifierSet._check_relation_operandw  s=    %..566%"6"6JKK #7r&   c                ~    U R                  U5        U R                  5       R                  UR                  5       5      $ )a  Return whether every version matching this set also matches other.

:raises ValueError:
    If either set uses ``===`` specifiers, or the two sets were
    given different ``prereleases`` arguments (unset on one side
    counts as different).
:raises TypeError:
    If other is not a :class:`SpecifierSet`.

>>> SpecifierSet(">=3.12,<3.13").is_subset(SpecifierSet(">=3.12"))
True
>>> SpecifierSet(">=3.12").is_subset(SpecifierSet(">=3.12,<3.13"))
False

.. versionadded:: 26.3
)rr  ro  	is_subsetrg   s     r'   ru  SpecifierSet.is_subset}  s0    " 	$$U+}}(()9::r&   c                ~    U R                  U5        U R                  5       R                  UR                  5       5      $ )a  Return whether every version matching other also matches this set.

:raises ValueError:
    If either set uses ``===`` specifiers, or the two sets were
    given different ``prereleases`` arguments (unset on one side
    counts as different).
:raises TypeError:
    If other is not a :class:`SpecifierSet`.

>>> SpecifierSet(">=3.12").is_superset(SpecifierSet(">=3.12,<3.13"))
True

.. versionadded:: 26.3
)rr  ro  is_supersetrg   s     r'   rx  SpecifierSet.is_superset  s0     	$$U+}}**5>>+;<<r&   c                ~    U R                  U5        U R                  5       R                  UR                  5       5      $ )a  Return whether this set and other share no matching versions.

:raises ValueError:
    If either set uses ``===`` specifiers, or the two sets were
    given different ``prereleases`` arguments (unset on one side
    counts as different).
:raises TypeError:
    If other is not a :class:`SpecifierSet`.

>>> SpecifierSet("<3.12").is_disjoint(SpecifierSet(">=3.12"))
True
>>> SpecifierSet("<3.12").is_disjoint(SpecifierSet(">=3.11"))
False

.. versionadded:: 26.3
)rr  ro  is_disjointrg   s     r'   r{  SpecifierSet.is_disjoint  s0    " 	$$U+}}**5>>+;<<r&   c                $    U R                  U5      $ )a  Return whether or not the item is contained in this specifier.

:param item: The item to check for.

This is used for the ``in`` operator and behaves the same as
:meth:`contains` with no ``prereleases`` argument passed.

>>> "1.2.3" in SpecifierSet(">=1.0.0,!=1.0.1")
True
>>> Version("1.2.3") in SpecifierSet(">=1.0.0,!=1.0.1")
True
>>> "1.0.1" in SpecifierSet(">=1.0.0,!=1.0.1")
False
>>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1")
True
>>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
True
r   r   s     r'   r   SpecifierSet.__contains__  r   r&   c           	     d   [        U5      nUb  U(       a  UR                  (       a  SnUb&  U R                  (       a  [        U[        5      (       d  UnOUnUb  U R                  (       d  UR
                  c  U R                  (       a  UR                  (       a  USL d  Uc  U R                  SL a  gU R                  nUcC  U R                   H  n[        Xt5      nUc    OU(       a  M    g   gU R                  5       =o`l        [        Xd5      $ [        [        U R                  U/US95      5      $ )aT  Return whether or not the item is contained in this SpecifierSet.

:param item:
    The item to check for, which can be a version string or a
    :class:`~packaging.version.Version` instance.
:param prereleases:
    Whether or not to match prereleases with this SpecifierSet. If set to
    ``None`` (the default), it will follow the recommendation from :pep:`440`
    and match prereleases, as there are no other versions.
:param installed:
    Whether or not the item is installed. If set to ``True``, it will
    accept prerelease versions even if the specifier does not allow them.

>>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.2.3")
True
>>> SpecifierSet(">=1.0.0,!=1.0.1").contains(Version("1.2.3"))
True
>>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.0.1")
False
>>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1")
True
>>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False).contains("1.3.0a1")
False
>>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True)
True

.. versionchanged:: 26.0

    With ``prereleases=None``, a prerelease now matches. A single
    version has no alternatives, so the :pep:`440` rule to accept
    prereleases when nothing else satisfies the specifiers applies.
    Earlier versions rejected it. An unparsable version now returns
    ``False`` instead of raising :exc:`~packaging.version.InvalidVersion`.
TFr   )r   r   r  r+   r   rC   r  r   r   rN   r]  r   r2   r   ry   )	r]   rr   rl   	installedr   
check_itemboundsr/   r   s	            r'   rs   SpecifierSet.contains  s   P !&91F1FK ?t22:dG;T;TJ J ''%$$u$'D,=,=,F\\F~
 !KKD'6E} 5$ (  (,(8(8(::&v77Dj\{KLMMr&   c                    g r#   r%   rv   s       r'   ry   SpecifierSet.filter$  r{   r&   c                    g r#   r%   rv   s       r'   ry   r  ,  r}   r&   c                @  ^^ Uc  U R                   b  U R                   nU R                  (       ac  U R                  (       a&  U R                  mUU4S jU 5       n[        UTU5      $ U R                  nUc  U R                  5       n[        XQTU5      $ [        UTU5      $ )aG  Filter items in the given iterable, that match the specifiers in this set.

:param iterable:
    An iterable that can contain version strings and
    :class:`~packaging.version.Version` instances. The items in the
    iterable will be filtered according to the specifier.
:param prereleases:
    Whether or not to allow prereleases in the returned iterator. If set to
    ``None`` (the default), it will follow the recommendation from :pep:`440`
    and match prereleases if there are no other versions.
:param key:
    A callable that takes a single argument (an item from the iterable) and
    returns a version string or :class:`~packaging.version.Version`
    instance to be used for filtering.

>>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
['1.3']
>>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", Version("1.4")]))
['1.3', <Version('1.4')>]
>>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.5a1"]))
['1.5a1']
>>> list(SpecifierSet(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
['1.3', '1.5a1']
>>> list(SpecifierSet(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
['1.3', '1.5a1']
>>> list(SpecifierSet(">=1.2.3").filter(
... [{"ver": "1.2"}, {"ver": "1.3"}],
... key=lambda x: x["ver"]))
[{'ver': '1.3'}]

An "empty" SpecifierSet will filter items based on the presence of prerelease
versions in the set.

>>> list(SpecifierSet("").filter(["1.3", "1.5a1"]))
['1.3']
>>> list(SpecifierSet("").filter(["1.5a1"]))
['1.5a1']
>>> list(SpecifierSet("", prereleases=True).filter(["1.3", "1.5a1"]))
['1.3', '1.5a1']
>>> list(SpecifierSet("").filter(["1.3", "1.5a1"], prereleases=True))
['1.3', '1.5a1']

.. versionchanged:: 26.0

    Prerelease filtering now follows the PEP 440 recommendation of
    yielding prereleases only when no final release is present.

.. versionchanged:: 26.1

    Added the ``key`` parameter.
c              3  d   >^#    U  H$  m[        UU4S  jT 5       5      (       d  M   Tv   M&     g7f)c              3  Z   >#    U  H   nUR                  Tc  TOT" T5      SS9v   M"     g 7f)NTr   r   )r   r  rr   rx   s     r'   r  0SpecifierSet.filter.<locals>.<genexpr>.<genexpr>z  s0      !&A 

3;4CISW
X!&s   (+N)rA  )r   rr   rx   rC  s    @r'   r  &SpecifierSet.filter.<locals>.<genexpr>w  s/       ( !&  D (s   0	0)rl   r  r  r  r   r]  r   )r]   rw   rl   rx   r  r   rC  s      `  @r'   ry   r  4  s    x 4#3#3#?**K;;"" ( 1#{KK\\F~))+#Fc;GG )3DDr&   r  )r%  zstr | Iterable[Specifier]rl   r   r   r   )r   ztuple[Specifier, ...]r   r  )r   z)tuple[tuple[Specifier, ...], bool | None]r  r   r   )rh   zSpecifierSet | strr   r!   r   )r   zIterator[Specifier]r  )r   r2   )r   zranges.VersionRange)rh   r   r   r   )rh   r!   r   r2   )rr   r	  r   r2   r   )rr   r	  rl   r   r  r   r   r2   r   r   r   r   )"rQ   rR   rS   rT   rU   r   r   r,  r   rl   r   r   r   r   r`   rd   rP  ri   rU  rX  r]  rb  r`  ro  rr  ru  rx  r{  r   rs   r   r   ry   rV   r%   r&   r'   r!   r!     s   $I 13#'*(-*( !*( 
	*(X  & & &07GrB*A-@C4 !
!F%@N6L;(=$=(#0 $(!%	VNVN !VN 	VN
 
VNp __ $(	+.+ !+ 	+
 
&+ + __ $(.1	 ! ,	
 
  $(7;	SESE !SE 5	SE
 
SE SEr&   r!   c              #  p  #    / n/ nSnU  H  n[        Uc  UOU" U5      5      nUc0  U(       a  Uv   O"UR                  U5        UR                  U5        ML  UR                  (       d  U(       d  U Sh  vN   SnUv   Mv  U(       a  M  UR                  U5        M     U(       d  U Sh  vN   gg N= N7f)z?Filter per PEP 440: exclude prereleases unless no finals exist.FNT)r   appendr   )rw   rx   all_nonfinalarbitrary_stringsfound_finalrr   rI   s          r'   r  r    s      !L#%KTC> 
!((.##D)##,,,"J {%1 6   - 	 s*   A2B64B25B6
!B6+B4,B64B6)r   z	list[str])r/   r   r   zTypeGuard[tuple[str, str]])r3   r   r   zTypeGuard[bool | None])rH   r    rI   r   r   r   )r  r   rx   r   rl   r   r   r   )rw   r   rx   r   r   r   )<rU   
__future__r   r   r  r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r   utilsr   r   r   syscollections.abcr   r   r   version_infor   typing_extensionsr   r   r   r$   r(   r0   r4   r5   r.   r	  r6   __ge____le__ri   __ne__r<   r  rN   rO  r   ABCMetar   r    r  r!   r  r%   r&   r'   <module>r     sW   # 
 	  
 
 
 ( <<
7"$/!0 CL%1I  ..
..
..
..	F B :	z 	Sckk SlIO IOX	0  	,I
E= I
EX' ' "I' ' r&   