
    wg                    N   d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	m
Z
mZ ddlmZ ddlmZ eeef   Z e
de	      Zeeegef   Zdd
Z G d de      Z G d dej0                        Z G d de      Z ej6                  d      ZddZddZddZddZ  G d de      Z!y)z
.. testsetup::

    from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
    from packaging.version import Version
    )annotationsN)CallableIterableIteratorTypeVarUnion   )canonicalize_version)VersionUnparsedVersionVar)boundc                <    t        | t              st        |       } | S N)
isinstancer   )versions    l/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/setuptools/_vendor/packaging/specifiers.py_coerce_versionr      s    gw''"N    c                      e Zd ZdZy)InvalidSpecifiera  
    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'
    N)__name__
__module____qualname____doc__ r   r   r   r       s    r   r   c                  0   e Zd Zej                  d	d       Zej                  d
d       Zej                  dd       Zeej                  dd              Z	e	j                  dd       Z	ej                  ddd       Zej                  	 d	 	 	 	 	 dd       Zy)BaseSpecifierc                     y)z
        Returns the str representation of this Specifier-like object. This
        should be representative of the Specifier itself.
        Nr   selfs    r   __str__zBaseSpecifier.__str__-       r   c                     y)zF
        Returns a hash value for this Specifier-like object.
        Nr   r   s    r   __hash__zBaseSpecifier.__hash__4   r"   r   c                     y)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__zBaseSpecifier.__eq__:   r"   r   c                     y)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   prereleaseszBaseSpecifier.prereleasesC   r"   r   c                     y)zQSetter for :attr:`prereleases`.

        :param value: The value to set.
        Nr   r    values     r   r*   zBaseSpecifier.prereleasesL   r"   r   Nc                     y)zR
        Determines if the given item is contained within this specifier.
        Nr   )r    itemr*   s      r   containszBaseSpecifier.containsS   r"   r   c                     y)z
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr   )r    iterabler*   s      r   filterzBaseSpecifier.filterY   r"   r   returnstrr5   intr'   objectr5   boolr5   bool | Noner-   r;   r5   Noner   )r/   r6   r*   r=   r5   r;   r2   zIterable[UnparsedVersionVar]r*   r=   r5   zIterator[UnparsedVersionVar])r   r   r   abcabstractmethodr!   r$   r(   propertyr*   setterr0   r3   r   r   r   r   r   ,   s      	 
 	       	 
 	QU4CN	% r   r   )	metaclassc            	         e Zd ZdZdZdZ ej                  dez   ez   dz   ej                  ej                  z        Z
dddd	d
ddddZd&d'dZed(d       Zej                  d)d       Zed*d       Zed*d       Zd*dZd*dZed+d       Zd,dZd-dZd.dZd/dZd/dZd/dZd/dZd/dZd0d Zd0d!Zd/d"Zd1d#Z d2d3d$Z!	 d2	 	 	 	 	 d4d%Z"y)5	Specifiera?  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).
    z8
        (?P<operator>(~=|==|!=|<=|>=|<|>|===))
        a  
        (?P<version>
            (?:
                # 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 .*
                    |
                    (?:                                  # 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
                    (?:\+[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.
                (?<!==|!=|~=)         # We have special cases for these
                                      # operators so we want to make sure they
                                      # don't match here.

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?:                   # 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
            )
        )
        z^\s*z\s*$
compatibleequal	not_equalless_than_equalgreater_than_equal	less_thangreater_than	arbitrary)~===z!=<=>=<>===Nc                    | j                   j                  |      }|st        d|      |j                  d      j	                         |j                  d      j	                         f| _        || _        y)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: operatorr   N)_regexsearchr   groupstrip_spec_prereleases)r    specr*   matchs       r   __init__zSpecifier.__init__   sm     ""4("%8#ABB KK
#))+KK	"((*'

 (r   c                    | j                   | j                   S | j                  \  }}|dv r1|dk(  r|j                  d      r|d d }t        |      j                  ryy)N)rQ   rS   rR   rP   rV   rU   rT   rQ   .*TF)r^   r]   endswithr   is_prerelease)r    rX   r   s      r   r*   zSpecifier.prereleases   sm     ($$$
 !JJ'@@ 4G$4$4T$:!#2, w--r   c                    || _         y r   r^   r,   s     r   r*   zSpecifier.prereleases  
    !r   c                     | j                   d   S )z`The operator of this specifier.

        >>> Specifier("==1.2.3").operator
        '=='
        r   r]   r   s    r   rX   zSpecifier.operator       zz!}r   c                     | j                   d   S )zaThe version of this specifier.

        >>> Specifier("==1.2.3").version
        '1.2.3'
        r	   rk   r   s    r   r   zSpecifier.version  rl   r   c                    | j                   d| j                  nd}d| j                  j                   dt	        |       | dS )aT  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= rT   ()>)r^   r*   	__class__r   r6   r    pres     r   __repr__zSpecifier.__repr__&  sU       , T--01 	 4>>**+1SYM#bAAr   c                4     dj                   | j                   S )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{}{})formatr]   r   s    r   r!   zSpecifier.__str__8  s     v}}djj))r   c                x    t        | j                  d   | j                  d   dk7        }| j                  d   |fS )Nr	   r   rP   strip_trailing_zero)r
   r]   )r    canonical_versions     r   _canonical_speczSpecifier._canonical_specB  s>    0JJqM!%A$!6
 zz!}///r   c                ,    t        | j                        S r   )hashr}   r   s    r   r$   zSpecifier.__hash__J  s    D(())r   c                    t        |t              r	 | j                  t        |            }nt        || j                        st        S | j
                  |j
                  k(  S # t        $ r	 t        cY S w xY w)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   r6   rs   r   NotImplementedr}   r&   s     r   r(   zSpecifier.__eq__M  si    & eS!&s5z2 E4>>2!!##u'<'<<< $ &%%&s   A" "A43A4c                >    t        | d| j                  |          }|S )N	_compare_)getattr
_operators)r    opoperator_callables      r   _get_operatorzSpecifier._get_operatorj  s+    .5Idoob123/
 ! r   c           
         t        t        t        j                  t        t        |                  d d       }|dz  } | j                  d      ||      xr  | j                  d      ||      S )Nrc   rS   rQ   )_version_joinlist	itertools	takewhile_is_not_suffix_version_splitr   )r    prospectiver_   prefixs       r   _compare_compatiblezSpecifier._compare_compatiblep  sw     $$^^D5IJKCRP

 	$'t!!$'T: 
?Wt?Q?QRV?W@
 	
r   c                D   |j                  d      r_t        |j                  d      }t        |d d d      }t        |      }t        |      }t	        ||      \  }}|d t        |       }	|	|k(  S t        |      }
|
j                  st        |j                        }||
k(  S )Nrc   Frz   rd   )re   r
   publicr   _pad_versionlenr   local)r    r   r_   normalized_prospectivenormalized_spec
split_specsplit_prospectivepadded_prospective_shortened_prospectivespec_versions              r   _compare_equalzSpecifier._compare_equal  s    ==%9""&" 349RWXO (8J
 !//E F %11BJ$O!
 %77HZ$I!(J66 #4=L
  %%%k&8&89,..r   c                (    | j                  ||       S r   )r   r    r   r_   s      r   _compare_not_equalzSpecifier._compare_not_equal  s    &&{D999r   c                D    t        |j                        t        |      k  S r   r   r   r   s      r   _compare_less_than_equalz"Specifier._compare_less_than_equal       {))*gdm;;r   c                D    t        |j                        t        |      k\  S r   r   r   s      r   _compare_greater_than_equalz%Specifier._compare_greater_than_equal  r   r   c                    t        |      }||k  sy|j                  s8|j                  r,t        |j                        t        |j                        k(  ryyNFT)r   rf   base_versionr    r   spec_strr_   s       r   _compare_less_thanzSpecifier._compare_less_than  sT     x 
 T! !!k&?&?{//0GD<M<M4NN
 r   c                   t        |      }||kD  sy|j                  s8|j                  r,t        |j                        t        |j                        k(  ry|j                  ,t        |j                        t        |j                        k(  ryyr   )r   is_postreleaser   r   r   s       r   _compare_greater_thanzSpecifier._compare_greater_than  s     x 
 T! ""{'A'A{//0GD<M<M4NN ({//0GD<M<M4NN
 r   c                h    t        |      j                         t        |      j                         k(  S r   )r6   lowerr   s      r   _compare_arbitraryzSpecifier._compare_arbitrary  s&    ;%%'3t9??+<<<r   c                $    | j                  |      S )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")
        False
        >>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
        True
        r0   r    r/   s     r   __contains__zSpecifier.__contains__      & }}T""r   c                    || j                   }t        |      }|j                  r|sy| j                  | j                        } ||| j
                        S )al  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:`Version` instance.
        :param prereleases:
            Whether or not to match prereleases with this Specifier. If set to
            ``None`` (the default), it uses :attr:`prereleases` to determine
            whether or not prereleases are allowed.

        >>> 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")
        False
        >>> Specifier(">=1.2.3", prereleases=True).contains("1.3.0a1")
        True
        >>> Specifier(">=1.2.3").contains("1.3.0a1", prereleases=True)
        True
        F)r*   r   rf   r   rX   r   )r    r/   r*   normalized_itemr   s        r   r0   zSpecifier.contains	  sY    4 **K *$/
 (( /3.@.@.O $,,??r   c              #     K   d}g }d||ndi}|D ]S  }t        |      } | j                  |fi |s"|j                  r |s| j                  s|j	                  |       Nd}| U |s|r|D ]  }|  yyyw)aO  Filter items in the given iterable, that match the specifier.

        :param iterable:
            An iterable that can contain version strings and :class:`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 be intelligently decide whether to allow
            prereleases or not (based on the :attr:`prereleases` attribute, and
            whether the only versions matching are prereleases).

        This method is smarter than just ``filter(Specifier().contains, [...])``
        because it implements the rule from :pep:`440` that a prerelease item
        SHOULD be accepted if no other versions match the given specifier.

        >>> 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']
        Fr*   NT)r   r0   rf   r*   append)r    r2   r*   yieldedfound_prereleaseskwr   parsed_versions           r   r3   zSpecifier.filter5  s     < K,C[N   	"G,W5Nt}}^2r2 "//4#3#3%,,W5 #G!M	"( ,,  -ws   0A9AA9rp   N)r_   r6   r*   r=   r5   r?   )r5   r;   r>   r4   )r5   ztuple[str, str]r7   r9   )r   r6   r5   CallableOperator)r   r   r_   r6   r5   r;   )r   r   r   r6   r5   r;   )r/   zstr | Versionr5   r;   r   )r/   UnparsedVersionr*   r=   r5   r;   r@   )#r   r   r   r   _operator_regex_str_version_regex_strrecompileVERBOSE
IGNORECASErY   r   ra   rC   r*   rD   rX   r   rv   r!   r}   r$   r(   r   r   r   r   r   r   r   r   r   r   r0   r3   r   r   r   rG   rG   c   sR   \| RZZ%%(::WD


R]]"F "	J(4  . " "    B$* 0 0*=:!
(&/P:<<0<=#**@Z RV;4;CN;	%;r   rG   z^([0-9]+)((?:a|b|c|rc)[0-9]+)$c                   g }| j                  d      \  }}}|j                  |xs d       |j                  d      D ]J  }t        j	                  |      }|r |j                  |j                                :|j                  |       L |S )a  Split version into components.

    The split components are intended for version comparison. The logic does
    not attempt to retain the original version string, so joining the
    components back with :func:`_version_join` may not produce the original
    version string.
    !0.)
rpartitionr   split_prefix_regexrZ   extendgroups)r   resultepochr   restr/   r`   s          r   r   r   v  s~     F'',NE1d
MM%,3

3  $$T*MM%,,.)MM$  Mr   c                6    | ^}}| ddj                  |       S )zJoin split version components into a version string.

    This function assumes the input came from :func:`_version_split`, where the
    first component must be the epoch (either empty or numeric), and all other
    components numeric.
    r   r   )join)
componentsr   r   s      r   r   r     s'     LEDWAchhtn%&&r   c                .     t         fddD               S )Nc              3  @   K   | ]  }j                  |        y wr   )
startswith).0r   segments     r   	<genexpr>z!_is_not_suffix.<locals>.<genexpr>  s!      '-6"s   )devabrcpost)any)r   s   `r   r   r     s"     1P   r   c                   g g }}|j                  t        t        j                  d |                    |j                  t        t        j                  d |                   |j                  | t	        |d         d         |j                  |t	        |d         d         |j                  ddgt        dt	        |d         t	        |d         z
        z         |j                  ddgt        dt	        |d         t	        |d         z
        z         t        t        j                  j                  |            t        t        j                  j                  |            fS )Nc                "    | j                         S r   isdigitxs    r   <lambda>z_pad_version.<locals>.<lambda>  s     r   c                "    | j                         S r   r   r   s    r   r   z_pad_version.<locals>.<lambda>  s    !))+ r   r   r	   r   )	r   r   r   r   r   insertmaxchainfrom_iterable)leftright
left_splitright_splits       r   r   r     s5    "J d9../DdKLMtI//0EuMNO d3z!}-/01uSQ0234 a#QKN(;c*Q->P(P!QQRq3%#aZ]);c+a.>Q)Q"RRS 	Y__**:67Y__**;78 r   c                      e Zd ZdZ	 	 d	 	 	 	 	 ddZedd       Zej                  dd       ZddZddZ	ddZ
dd	Zdd
ZddZddZddZ	 	 d	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 ddZy)SpecifierSetzThis 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.
    Nc                "   t        |t              rc|j                  d      D cg c]#  }|j                         s|j                         % }}t	        t        t        |            | _        || _        yt	        |      | _        || _        yc c}w )a  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.
        ,N)	r   r6   r   r\   	frozensetmaprG   _specsr^   )r    
specifiersr*   ssplit_specifierss        r   ra   zSpecifierSet.__init__  s{    , j#& 4>3C3CC3HVaAGGI	VV $C	3C$DEDK (	 $J/DK (  Ws
   BBc                    | j                   | j                   S | j                  sy t        d | j                  D              S )Nc              3  4   K   | ]  }|j                     y wr   r*   r   r   s     r   r   z+SpecifierSet.prereleases.<locals>.<genexpr>  s     6Q1==6s   )r^   r   r   r   s    r   r*   zSpecifierSet.prereleases  s?     ($$$
 {{ 6$++666r   c                    || _         y r   rh   r,   s     r   r*   zSpecifierSet.prereleases  ri   r   c                ^    | j                   d| j                  nd}dt        |       | dS )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)>
        ro   rp   z<SpecifierSet(rr   )r^   r*   r6   rt   s     r   rv   zSpecifierSet.__repr__  sD       , T--01 	  D	}SE44r   c                X    dj                  t        d | j                  D                    S )an  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  2   K   | ]  }t        |        y wr   )r6   r  s     r   r   z'SpecifierSet.__str__.<locals>.<genexpr>  s     ;!s1v;s   )r   sortedr   r   s    r   r!   zSpecifierSet.__str__	  s"     xx;t{{;;<<r   c                ,    t        | j                        S r   )r   r   r   s    r   r$   zSpecifierSet.__hash__  s    DKK  r   c                   t        |t              rt        |      }nt        |t              st        S t               }t	        | j
                  |j
                  z        |_        | j                  |j                  |j                  |_        |S | j                  |j                  | j                  |_        |S | j                  |j                  k(  r| j                  |_        |S t        d      )a  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')>
        zFCannot combine SpecifierSets with True and False prerelease overrides.)r   r6   r   r   r   r   r^   
ValueError)r    r'   	specifiers      r   __and__zSpecifierSet.__and__  s     eS! 'EE<0!! N	$T[[5<<%?@	$););)G%*%7%7I"  *u/A/A/I%)%6%6I"  %"4"44%)%6%6I"   r   c                    t        |t        t        f      rt        t        |            }nt        |t              st        S | j
                  |j
                  k(  S )a  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   r6   rG   r   r   r   r&   s     r   r(   zSpecifierSet.__eq__9  sD    & ec9-. U,EE<0!!{{ell**r   c                ,    t        | j                        S )z7Returns the number of specifiers in this specifier set.)r   r   r   s    r   __len__zSpecifierSet.__len__S  s    4;;r   c                ,    t        | j                        S )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')>]
        )iterr   r   s    r   __iter__zSpecifierSet.__iter__W  s     DKK  r   c                $    | j                  |      S )ar  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")
        False
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
        True
        r   r   s     r   r   zSpecifierSet.__contains__a  r   r   c                    t        t              st              | j                  sj                  ry|r!j                  rt        j                        t        fd| j                  D              S )a  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:`Version` instance.
        :param prereleases:
            Whether or not to match prereleases with this SpecifierSet. If set to
            ``None`` (the default), it uses :attr:`prereleases` to determine
            whether or not prereleases are allowed.

        >>> 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")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True).contains("1.3.0a1")
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True)
        True
        Fc              3  D   K   | ]  }|j                           yw)r  Nr   )r   r   r/   r*   s     r   r   z(SpecifierSet.contains.<locals>.<genexpr>  s     R1::d:<Rs    )r   r   r*   rf   r   allr   )r    r/   r*   	installeds    `` r   r0   zSpecifierSet.containsv  sm    < $(4=D
 **K t11++4,,-D RdkkRRRr   c                r   || j                   }| j                  r8| j                  D ]  }|j                  |t        |            }  t	        |      S g }g }|D ]A  }t        |      }|j                  r|s|r|j                  |       1|j                  |       C |s|r|t	        |      S t	        |      S )a.  Filter items in the given iterable, that match the specifiers in this set.

        :param iterable:
            An iterable that can contain version strings and :class:`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 be intelligently decide whether to allow
            prereleases or not (based on the :attr:`prereleases` attribute, and
            whether the only versions matching are prereleases).

        This method is smarter than just ``filter(SpecifierSet(...).contains, [...])``
        because it implements the rule from :pep:`440` that a prerelease item
        SHOULD be accepted if no other versions match the given specifier.

        >>> 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"]))
        []
        >>> 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']

        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']
        r  )r*   r   r3   r;   r  r   rf   r   )r    r2   r*   r_   filteredr   r/   r   s           r   r3   zSpecifierSet.filter  s    X **K
 ;; P;;xT+=N;OP>!
 24H:<  	*!0!6 "//#)006OOD)	*  1k6I-..>!r   r   )r   zstr | Iterable[Specifier]r*   r=   r5   r?   r<   r>   r4   r7   )r'   zSpecifierSet | strr5   r   r9   )r5   zIterator[Specifier])r/   r   r5   r;   )NN)r/   r   r*   r=   r  r=   r5   r;   r   r@   )r   r   r   r   ra   rC   r*   rD   rv   r!   r$   r  r(   r  r  r   r0   r3   r   r   r   r   r     s     13#'$(-$( !$( 
	$(L 7 7  " "5*=!@+4 !#0 $(!%	7S7S !7S 	7S
 
7St RVM"4M"CNM"	%M"r   r   )r   r   r5   r   )r   r6   r5   	list[str])r   r  r5   r6   )r   r6   r5   r;   )r   r  r   r  r5   ztuple[list[str], list[str]])"r   
__future__r   rA   r   r   typingr   r   r   r   r   utilsr
   r   r   r6   r   r   r;   r   r   r  r   ABCMetar   rG   r   r   r   r   r   r   r   r   r   r   <module>r"     s    # 
  	 ? ? ' %1I WcND01 	z 	4ckk 4nM M` 

<=,'*J"= J"r   