+
    yjnD                   z   R t ^ RIHt ^ RIt^ RIt^ RIHtHtHtHt ^RI	H
t
HtHtHtHtHtHtHtHtHtHtHtHtHtHtHt ^RIHt ]'       d   ^ RIHtHtHtH t  ^RI	H!t! ^RI"H#t# R	.t$]! R
4      t%]]]&3,          t']! R]'R7      t(^t) ! R R]PT                  4      t+R R lt,R R lt-R R lt.R R lt/R R lt0R R lt1R R lt2R R lt3R R  lt4R! R" lt5R# R$ lt6R% R& lt7R' R( lt8R) R* lt9R+ R, lt:R- R. lt;R/ R0 lt<R1 R2 lt=R3 R4 lt>R5 R6 lt?])3R7 R8 llt@R9 R: ltAR; R< ltBR= R> ltC ! R? R	4      tDR# )@a	  Public :class:`VersionRange` API.

A set-algebra view of the versions accepted by a
:class:`~packaging.specifiers.SpecifierSet`. Ranges support intersection,
union, complement, and difference; membership and filtering match the
originating specifier set; and conversion back to a
:class:`~packaging.specifiers.SpecifierSet` is available where a PEP 440 form
exists.

.. testsetup::

    from packaging.ranges import VersionRange
    from packaging.specifiers import SpecifierSet
    from packaging.version import Version
)annotationsN)TYPE_CHECKINGAnyTypeVarUnion)
FULL_RANGEMIN_VERSIONNEG_INFPOS_INFBoundaryKindBoundaryVersion
LowerBound
UpperBoundcoerce_versionfilter_by_rangesintersect_rangesleast_version_abovematches_bounds_onlyrange_is_emptyranges_are_prerelease_onlytrim_release)Version)CallableIterableIteratorSequence)Interval)SpecifierSetVersionRangeTUnparsedVersionVar)boundc                      ] tR t^KtRt]P                  ! 4       t]P                  ! 4       t]P                  ! 4       t	Rt
R# )_SetOpzNThe binary set operation ``_combine_literals`` resolves over ``===`` literals. N)__name__
__module____qualname____firstlineno____doc__enumautoINTERSECTIONUNION
DIFFERENCE__static_attributes__r$       D/var/www/html/2rare/lib/python3.14/site-packages/packaging/ranges.pyr#   r#   K   s&    X99;LIIKEJr0   r#   c                   V ^8  d   QhRR/# )   returnz	list[str]r$   )formats   "r1   __annotate__r6   S   s       r0   c                     \         # N)__all__r$   r0   r1   __dir__r:   S   s    Nr0   c               $    V ^8  d   QhRRRRRR/# )r3   leftSequence[Interval]rightr4   list[Interval]r$   )r5   s   "r1   r6   r6   \   s&     4 4
44 4r0   c                   V '       g   \        V4      # V'       g   \        V 4      # . p^ ;r4V\        V 4      8  dv   V\        V4      8  df   W,          ^ ,          W,          ^ ,          8:  d#   VP                  W,          4       V^,          pKc  VP                  W,          4       V^,          pK  VP                  WR 4       VP                  WR 4       V^ ,          .pVR,           EF  w  rgVR,          w  rV	P                  e*   VP                  e   V	P                  VP                  8  d   Rp
MV	P                  VP                  8X  d"   V	P
                  ;'       g    VP
                  p
MU\        V	P                  V	P
                  '       * 4      p\        VP                  VP
                  '       * 4      p\        W4      p
V
'       d   V\        W4      3VR&   K  VP                  Wg34       EK  	  V# )zUnion two sorted, non-overlapping interval lists.

A linear merge over the two pre-sorted inputs followed by a single
coalescing pass: adjacent or overlapping intervals collapse so the result
is itself sorted and non-overlapping.
N   NNT)
listlenappendextendversion	inclusiver   r   r   max)r<   r>   merged_input
left_indexright_indexmergedlowerupper
prev_lower
prev_upperoverlaps	gap_lower	gap_uppers   &&           r1   _union_rangesrV   \   s    E{Dz#%L  J
s4y
 [3u:%=A%"4Q"77 01!OJ 231K[)*l+,*1o.F$R((!'
 &}}$!!EMM1H5==0!++>>uH
 #:#5#5:;O;O7OPI"5==eoo2EFI%i;H$c*&<=F2JMM5.)- )0 Mr0   c                    V ^8  d   QhRRRR/# )r3   rangesr=   r4   r?   r$   )r5   s   "r1   r6   r6      s     % %1 %n %r0   c                L   V '       g   \        \        4      # . pRpV  F  w  r4VfL   VP                  e=   \        VP                  VP                  '       * 4      pVP                  \        V34       M\\        VP                  VP                  '       * 4      p\        VP                  VP                  '       * 4      pVP                  We34       TpK  	  Vf   Q hVP                  e=   \        VP                  VP                  '       * 4      pVP                  V\        34       V# )zComplement a sorted, non-overlapping interval list.

Yields the gaps between intervals plus a leading gap before the first and
a trailing gap after the last. Bound inclusivity flips so that
complement-of-complement round-trips back to the input.
N)	rD   r   rH   r   rI   rF   r	   r   r
   )rX   resultrR   rO   rP   rU   rT   s   &      r1   _complement_rangesr[      s     JF$(J }}(&u}}%//6IJ	w	23":#5#5:;O;O7OPI"5==eoo2EFI MM901
! & !!!%z11z7K7K3KL	y'*+Mr0   c                    V ^8  d   QhRRRR/# r3   boundstuple[Interval, ...]r4   r$   )r5   s   "r1   r6   r6      s      1 6J r0   c                "   V '       g   V # V ^ ,          w  r\        \        V4      '       d
   V R,          # VP                  '       dI   \        VP                  \
        4      '       d)   VP                  \        8:  d   \        V3.V R,          O5# V # )aQ  Collapse the PEP 440 floor in a sorted interval list.

Only the first interval can touch ``0.dev0`` (the minimum version). An
inclusive lower at or below it admits everything below, the same as
``-inf``, so ``>=0.dev0`` becomes the one canonical full range. An
exclusive upper at or below it leaves the interval empty, so it is dropped.
rA   )r   r	   rI   
isinstancerH   r   r   )r^   rO   rP   s   &  r1   _canonical_floorrb      sr     !9LEgu%%bz 	u}}g..MM[(% .6":..Mr0   c                    V ^8  d   QhRRRR/# )r3   rH   r   r4   zBoundaryVersion | Noner$   )r5   s   "r1   r6   r6      s     & &7 &/E &r0   c                   V P                   f   R# RpV P                  ei   V P                   ^ 8X  dX   V P                  fJ   V P                  w  r#V^8  d4   \        V P	                  W#^,
          3RR7      \
        P                  4      pMV P                   ^8  d=   \        V P	                  V P                   ^,
          R7      \
        P                  4      pMV P                   ^ 8X  dq   V P                  ec   V P                  ^ 8X  d   V P	                  RRR7      M#V P	                  V P                  ^,
          RR7      p\        V\
        P                  4      pVe   \        V4      V 8X  d   V# R# )a  The boundary whose least successor is *version*, or ``None``.

Inverse of :func:`~packaging._ranges.least_version_above`. A plain version
that is exactly such a successor (``1.0a2.dev0`` sits just above
``AFTER_POSTS(1.0a1)``) folds back to that boundary, so ``>=1.0a2.dev0`` and
``>1.0a1`` share one form. The proposed boundary is confirmed by
round-tripping through ``least_version_above``.
N)predevrf   postrf   )	rf   re   ri   r   __replace__r   AFTER_POSTSAFTER_LOCALSr   )rH   	candidatekindnumberbases   &    r1   _predecessor_boundaryrq      s8    {{(,I{{7;;!#38L{{Q;'##z(:#E((I 
	#GKK!O4l6O6O
	 
	gll6 ||q  Tt4$$',,*:$E 	
 $D,*C*CD	!4Y!?7!Jr0   c                    V ^8  d   QhRRRR/# r]   r$   )r5   s   "r1   r6   r6      s      . 3G r0   c                   . pV  F  w  r#Y#rT\        VP                  \        4      '       d9   VP                  '       d'   \	        VP                  4      pVe   \        VRR7      p\        VP                  \        4      '       d9   VP                  '       g'   \	        VP                  4      pVe   \        VRR7      pVP                  WE34       K  	  \        V4      # )a  Fold least-successor bounds to their boundary form.

``>=1.0a2.dev0`` and ``>1.0a1`` denote the same set, so both must reduce to
one representation for ``==`` and ``hash`` to agree. An inclusive lower or
exclusive upper sitting on a boundary's least successor becomes that
boundary; the engine's emptiness check has already dropped the synthetic
gaps such intervals would otherwise leave.
FrI   T)	ra   rH   r   rI   rq   r   r   rF   tuple)r^   rZ   rO   rP   	new_lower	new_upperboundarys   &      r1   _canonicalizery      s      F$9emmW--%///,U]];H#&x5A	emmW--eooo,U]];H#&x4@	y,-  =r0   c               (    V ^8  d   QhRRRRRRRR/# )r3   r^   r_   admit_arbitraryboolliteralstrr4   r$   )r5   s   "r1   r6   r6     s,     / / /37/BE/	/r0   c                \    \        V4      pVf   T;'       d
    V \        8H  # \        W4      # )a  True when the bounds (plus arbitrary admission) admit ``literal``.

Skips the explicit admit/reject sets, which the caller layers on top. A
non-version string matches via ``admit_arbitrary`` only on full bounds;
on narrower bounds the flag is metadata only.
)r   r   r   )r^   r{   r}   parseds   &&& r1   _struct_admitsr     s1     G$F~776Z#77v..r0   c                    V ^8  d   QhRRRR/# )r3   valuezBoundaryVersion | Versionr4   r~   r$   )r5   s   "r1   r6   r6   +  s      7 C r0   c                    \        V \        4      '       d'   V P                   RV P                  P                   R2# \        V 4      # )z?Printout for a bound's inner value, kind-tagged for boundaries.[])ra   r   rH   rn   namer~   )r   s   &r1   _bound_version_strr   +  s9    %))--%**//!2!44u:r0   c                    V ^8  d   QhRRRR/# )r3   r!   r   r4   r~   r$   )r5   s   "r1   r6   r6   2       ; ; ; ;r0   c                    V P                   f   R# V P                  '       d   RMRpV \        V P                   4       2# )Nz(-infr   (rH   rI   r   r!   brackets   & r1   _format_lowerr   2  s8    }}___c#GY)%--89::r0   c                    V ^8  d   QhRRRR/# )r3   r!   r   r4   r~   r$   )r5   s   "r1   r6   r6   9  r   r0   c                    V P                   f   R# V P                  '       d   RMRp\        V P                   4       V 2# )Nz+inf)r   )r   r   s   & r1   _format_upperr   9  s7    }}___c#G /0	::r0   c                    V ^8  d   QhRRRR/# )r3   	intervalsr=   r4   r~   r$   )r5   s   "r1   r6   r6   @  s      !3  r0   c                2    RP                  R V  4       4      # )zARender a sorted interval list as ``lower, upper | lower, upper``. | c              3  X   "   T F   w  r\        V4       R \        V4       2x  K"  	  R# 5i), N)r   r   ).0rO   rP   s   &  r1   	<genexpr>$_format_intervals.<locals>.<genexpr>B  s,      NWle=
 =#7"89is   (*)join)r   s   &r1   _format_intervalsr   @  s     :: NW  r0   c                    V ^8  d   QhRRRR/# )r3   rH   r   r4   r|   r$   )r5   s   "r1   r6   r6   R  s      g $ r0   c                    V P                   ^ 8H  ;'       d;    V P                  RJ ;'       d%    V P                  RJ ;'       d    V P                  RJ # )zFTrue when version is exactly ``X[.Y]*.dev0`` (the shape ``<X`` makes).N)rf   re   ri   local)rH   s   &r1   _is_dev0_versionr   R  sY     	q 	" 	"KK4	" 	"LLD 	" 	" MMT!	r0   c                    V ^8  d   QhRRRR/# )r3   rH   r   r4   list[str] | Noner$   )r5   s   "r1   r6   r6   \  s      *  *'  *&6  *r0   c                   V P                   ^ 8w  g   V P                  f   V P                  e   R# V P                  e<   V P                  ^8  d   R# RV P	                  V P                  ^,
          RR7       2.# \        V P                  4      pVR,          pV^8  d   R# . VRR OV^,
          N5p\        P                  ! V P                  VR7      pV P                  ^ 8X  d   \        V4      '       g   RV R2.# RV 2RV R2.# )	aQ  A prerelease-free spelling for an inclusive ``[version`` lower, or ``None``.

Several ``[V`` lowers come from an operator whose own spelling carries no
synthetic ``.dev0``. Recovering that spelling gives the range an empty opt-in
region, so it is offered in the prerelease-free spelling mode (see
:meth:`VersionRange.to_specifier_set`).
N>rh   epochrelease!=.*>=rC   )rf   re   r   ri   rj   r   r   r   
from_partsr   any)rH   familylastbelow_releasebelows   &    r1   _clean_lowerr   \  s     {{a7;;2gmm6O ||<<!G''W\\A-=4'HIJKK '//*F":Dax,fSbk,4!8,MW]]MJE }}#m"4"4UG2LBugR.))r0   c               $    V ^8  d   QhRRRRRR/# )r3   rO   r   rP   r   r4   z tuple[Version, int, bool] | Noner$   )r5   s   "r1   r6   r6     s$     ./ ././(./%./r0   c                   V P                   p\        V\        4      '       dR   VP                  \        P
                  8w  d   R# VP                   pVP                  f   R# VP                  ^,           pM@\        V\        4      '       d)   V P                  '       d   VP                  ^ 8w  d   R# ^ pMR# VP                  ^ 8X  d   R# VP                  f   VP                  f   VP                  e   R# \        \        VP                  4      4      '       d   R# \        P                   ! VP                  R^ R7      p\#        VR4      pW8  d   R# \        P                   ! VP                  RR7      pWcW8H  3# )am  The ``E!0`` family of a lower sitting on an epoch>0 zero-family floor.

An epoch>0 zero-family base such as ``1!0.dev0`` has no ``>=P,!=P.*`` spelling
since no version sorts below ``E!0`` within the epoch. While the interval
stays within ``==E!0.*`` it is that wildcard, trimmed by the upper and with a
leading ``.dev`` run excluded: an ``AFTER_LOCALS(E!0.dev(k))`` lower drops
``E!0.dev0..E!0.dev(k)``, a plain inclusive ``E!0.dev0`` lower drops none.
Returns the ``E!0`` family, how many leading ``.dev`` releases to exclude, and
whether the upper sits at the family cap (so ``==E!0.*`` needs no upper), else
``None``.
N)r   r   rf   Fr   )rB       )rH   ra   r   rn   r   rl   rf   r   rI   r   re   ri   r   r   r   r   r   r   )rO   rP   rH   excluded_devsnext_familycapr   s   &&     r1   _epoch_floor_lowerr     s    mmG'?++<<<444//;;a	GW	%	%%/// ;;! }}{{',,":gmm>W
<()) $$7==$ANK
[%
(C{gmmTBF%,..r0   c                    V ^8  d   QhRRRR/# )r3   r   r   r4   r   r$   )r5   s   "r1   r6   r6     s      w +; r0   c                    V \         8:  d   . # \        V 4      pVe   V# V P                  f/   V P                  ^ 8X  d   V P	                  RRR7      pRV 2RV 2.# R# )a2  Prerelease-free fragments for ``[family, ..)``, or ``None`` if it has none.

``family`` is an ``X.dev0``. The floor gives ``[]`` (every version); a release
base its ``_clean_lower`` family-floor spelling (``!=0.*`` ...); an ``X.post0``
base ``>=X,!=X``. A pre-release base has no prerelease-free spelling.
Nrh   r   r   )r   r   re   ri   rj   )r   cleanrp   s   &  r1   _dev_family_anchorr     sj     	 EzzfkkQ.!!t!6TFr$[))r0   c               $    V ^8  d   QhRRRRRR/# )r3   rO   r   	keep_dev0r|   r4   r   r$   )r5   s   "r1   r6   r6     s"     >" >" >" >"9I >"r0   c                   V P                   pVf   . # \        V\        4      '       Ed   VP                  \        P
                  8X  d   RVP                    2.# VP                   pV\        8:  d   RV 2.# V'       g   VP                  e   VP                  ^ R7      p\        V4      pVee   VP                  ^,           \        8  d   R# \        VP                  ^,           4       Uu. uF  pRVP                  VR7       2NK  	  ppWW,           # M"\        V4      pVe   \        V4      MRp	V	e   V	# RV 2RV 2.# V P                  '       g   R# V'       g   \        V4      p	V	e   V	# RV 2.# u upi )a  Encode a lower bound as specifier fragments, or ``None``.

``[]`` for ``-inf``. An ``AFTER_POSTS(V)`` lower is ``>V``. An
``AFTER_LOCALS(V)`` lower is the set ``[successor, ..)`` and emits ``>=V,!=V``,
except in the prerelease-free spelling mode (``keep_dev0`` false), where it
recovers a spelling with no synthetic ``.dev0`` when one exists:
``>3.8.post1`` for a post release, or a dev family's anchor plus the dev run
up to V for a ``.dev`` release.
Nr   r   rg   r   )rH   ra   r   rn   r   rk   r   rf   rj   r   _MAX_EXCLUSION_RUNranger   r   rI   )
rO   r   lower_versioninnerr   anchordrun	successorr   s
   &&        r1   _encode_lowerr     s    MMM	-11!9!99--./00%%K L>! yy$
 **q*1+F3%yy1}'99#BG		TUBVBVQ"V//A/678BV   "<' & 0>	3<3HY/d$ L
 UG5'l++??? ]+L !!3s   )E1c               $    V ^8  d   QhRRRRRR/# )r3   rP   r   r   r|   r4   r   r$   )r5   s   "r1   r6   r6     s"     2 2 2 29I 2r0   c                r   V P                   pVf   . # \        V\        4      '       d   VP                  \        P
                  8X  dl   VP                   pV'       gR   VP                  fD   VP                  e6   VP                  f(   RVP                  VP                  ^,           R7       2.# RV 2.# \        V4      pVe   RV 2.# R# V P                  '       g\   VP                  ^ 8X  dA   VP                  f3   VP                  f%   V'       g   RVP                  RR7       2.# RV 2.# RV 2RV 2.# R# )a   Encode an upper bound as specifier fragments, or ``None``.

``[]`` for ``+inf``. In the prerelease-free spelling mode (``keep_dev0``
false) the ``<X`` spelling is used for the ``X.dev0`` upper that ``<X``
builds; otherwise the synthetic ``.dev0`` is kept so the range opts its
bounds in.
N<)ri   z<=rg   r   )rH   ra   r   rn   r   rl   re   ri   rf   rj   r   rI   r   )rP   r   upper_versionr   r   s   &&   r1   _encode_upperr     sA    MMM	-11 !:!::!))EII%JJ*II%
 E--5::>-BCDEEL>! (6	 	{O$$???
 "!!)##+M55$5?@ABB'((]O$=/&:;;r0   c               $    V ^8  d   QhRRRRRR/# )r3   rO   r   rP   r   r4   zVersion | Noner$   )r5   s   "r1   r6   r6   8  s&     F F* FZ FN Fr0   c                   \        V P                  \        4      '       g!   \        VP                  \        4      '       d   R# V P                  e   VP                  f   R# V P                  '       d   VP                  '       d   R# \	        V P                  4      '       d   \	        VP                  4      '       g   R# V P                  P
                  VP                  P
                  8w  d   R# \        V P                  P                  4      p\        VP                  P                  4      p\        \        V4      \        V4      4      pV^ 8  g   Q hVRV\        V4      ,
          ,          ,          pVRV\        V4      ,
          ,          ,          pVRR VRR 8w  d   R# VR,          VR,          ^,           8w  d   R# V P                  P                  VRR7      # )z;If ``[lower, upper)`` is the ``==V.*`` shape, return ``V``.N)r   rf   r   rC   )ra   rH   r   rI   r   r   r   r   rJ   rE   rj   )rO   rP   lower_releaseupper_releasepadded_lengths   &&   r1   _detect_equal_wildcardr   8  sd   %--11Z6 6 }} 5???eoooU]]++0@0O0O}}emm111 !6!67M !6!67MM*C,>?M1T]S-??@@MT]S-??@@MSb]3B//
 RM"-11==$$]$EEr0   c               (    V ^8  d   QhRRRRRRRR/# )	r3   rO   r   rP   r   r   r|   r4   r   r$   )r5   s   "r1   r6   r6   Z  s2     A% A%A%(A%59A%A%r0   c                  a
 V P                   e   VP                   e   \        V P                   \        4      '       g   \        VP                   \        4      '       gh   V P                  '       dV   VP                  '       dD   V P                   VP                   8X  d)   V P                   P                  e   RV P                    2.# \        V P                   \
        4      '       d   V P                  '       d   VP                  '       d   \        VP                   \        4      '       d_   VP                   P                  \        P                  8X  d6   VP                   P                   V P                   8X  d   RV P                    2.# \        W4      pVe   RV R2.# V'       g   \        W4      MRpVej   Vw  o
rVV\        8  d   R# RS
 R2.pVP                  V
3R l\        V4       4       4       V'       g#   \        W4      pVf   R# VP                  V4       V# \        W4      p	V	f   R# \        W4      pVf   R# W,           # )a	  Encode one interval as specifier fragments, or ``None``.

Special-cases the ``==V`` singleton (``[V, AFTER_LOCALS(V)]`` for a plain
``V``, and ``[V+local, V+local]`` for a local one) and the ``==V.*`` shape
so the fragment is one equality rather than a bound pair.
Nz==r   c              3  N   <"   T F  pR SP                  VR7       2x  K  	  R# 5ir   rg   Nrj   )r   r   r   s   & r1   r   #_encode_interval.<locals>.<genexpr>  s)     T?S!r&,,,345?S   "%)rH   ra   r   rI   r   r   rn   r   rl   r   r   r   rG   r   r   r   )rO   rP   r   wildcardfloorr   upper_at_cappartsupper_partslower_partsr   s   &&&       @r1   _encode_intervalr   Z  s    	!MM%5==/::5==/::OOOOOOMMU]]*MM+U]]O$%%
 	5=='**OOOOOOu}}o66MM,";";;MM!!U]]2U]]O$%%%e3HXJb!"" 5>u,4E.3+--fXR!Tu]?STT '9K"LL%1K1K$$r0   c               $    V ^8  d   QhRRRRRR/# )r3   
left_upperr   right_lowerr   r4   list[Version] | Noner$   )r5   s   "r1   r6   r6     s$     : ::)3::r0   c                   a \        V P                  \        4      '       d   \        V P                  4      pVf   R# M.V P                  e   V P                  '       d   R# V P                  p\        VP                  \        4      '       gE   VP                  e5   VP                  '       g#   VP                  V8X  d   VP
                  e   V.# R# VP                  P                  \        P                  8w  d   R# VP                  P                  pW#8X  d   V.# \        \        V\        P                  4      4      oSe   SP                  e   VP                  e   VP                  SP                  8  d   VP                  SP                  R7      S8X  df   VP                  SP                  ,
          ^,           \        8  d   R# V3R l\        SP                  VP                  ^,           4       4       pV.VO# R# )a  If the gap between two intervals is a ``!=V`` chain, list its points.

A plain exclusive left upper names the first excluded V directly; an inclusive
boundary left upper names it via its least successor. Adjacent exclusions
(``V`` and its immediate successors) share a single gap spanning a contiguous
dev run, so one gap can name a short chain: ``!=1.0,!=1.0.post0.dev0`` is one
gap from ``1.0`` up to ``AFTER_LOCALS(1.0.post0.dev0)``.
Nrg   c              3  H   <"   T F  pSP                  VR 7      x  K  	  R# 5i)rg   Nr   )r   r   seconds   & r1   r   $_detect_not_equal.<locals>.<genexpr>  s$     R2QQv!!a!((2Qs   ")ra   rH   r   r   rI   r   rn   r   rl   rf   rj   r   r   )r   r   firstr   r   r   s   &&   @r1   _detect_not_equalr     s    *$$o66 $J$6$67= 				#z';';';""k))?;;+)))##u,'7N<#<#<< &&D}w !8Q8Q!RSFJJ"HH HH

",6 88fjj 1$'99R%

DHHqL2QR}}r0   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r3   
lower_trimztuple[int, ...]
upper_trimr   intbudgetr4   r   r$   )r5   s   "r1   r6   r6     s:     2 222 2 	2
 2r0   c           
     *   ^ pV\        V 4      8  d/   V\        V4      8  d   W,          W,          8X  d   V^,          pK>  \        V 4      V^,           8  d   R# V RV p\        V 4      V8  d	   W,          M^ pW,          pWv,
          pW8  d   R# \        Wg4       U	u. uF   p	\        P                  ! V. VOV	N5R7      NK"  	  p
p	\        V4      V^,           8X  d   V
# \	        . VOVN5WV\        V^4      ,
          4      pVf   R# W,           # u up	i )a  Decompose the gap ``[L.dev0, U.dev0)`` into wildcard prefixes.

``lower_trim``/``upper_trim`` are trimmed release tuples with
``lower_trim < upper_trim`` lexicographically. The chain sweeps at the
first differing level. The gap is undecomposable when L has trailing
components below that level (the chain cannot escape L's subtree), or when
the chain, summed across levels, would exceed ``budget`` prefixes.
Nr   )rE   r   r   r   _decompose_dev0_gaprJ   )r   r   r   r   diffcommon	lower_val	upper_valspansegment	fragmentstails   &&&&        r1   r   r     s    Ds:3z?"
 00	
:!F$'
Od$:
 I I D} Y22G 	0B&0B'0BC2  
 :$(" &)j#dA,1FD |#s   &Dc               $    V ^8  d   QhRRRRRR/# )r3   r   r   r   r   r4   r   r$   )r5   s   "r1   r6   r6     s'     @ @J @Z @DT @r0   c                @  a \        W4      pVe   V Uu. uF  pRV 2NK
  	  up# V P                  p\        V\        4      '       d$   V P                  '       g   \        V4      '       g   R# VP                  p\        V\        4      '       d   VP                  '       d   Vo^ p\        pM\        V\        4      '       d   VP                  \        P                  8X  d~   VP                  '       gl   VP                  pVP                  e   VP                  ^,           \        8  d   R# VP                  ^ R7      oVP                  ^,           p\        V,
          pMR# \        S4      '       g   R# VP                  SP                  8w  g   VS8  d   R# \        \        VP                   4      \        SP                   4      VP                  V4      p	V	f   R# V	 U
u. uF	  p
RV
 R2NK  	  pp
VP#                  V3R l\%        V4       4       4       V# u upi u up
i )a'  Encode the gap between two adjacent intervals as ``!=`` fragments.

A point chain becomes ``!=V`` fragments and a dev0 family span becomes
``!=P.*`` prefixes, followed by a leading dev run in the last family when
the gap ends inside it. Any other gap has no exclusion form and returns
``None``.
Nr   rg   r   c              3  N   <"   T F  pR SP                  VR7       2x  K  	  R# 5ir   r   )r   r   
upper_dev0s   & r1   r   _encode_gap.<locals>.<genexpr>R  s)     VDUq:11a189:DUr   )r   rH   ra   r   rI   r   r   r   rn   r   rl   rf   rj   r   r   r   r   rG   r   )r   r   pointspointleft_vright_v
run_lengthr   rP   prefixesprefix
exclusionsr  s   &&          @r1   _encode_gapr    s    z7F*01&"UG&11 Fvw''''!!G'7##(=(=(=

#7O,,LLL555%%%
 99		A0B B&&1&-
YY]
#j0 J''||z'''6Z+?"V^^$Z''(	H 089fBvhb/J9VE*DUVVi 2d :s   HHc                    V ^8  d   QhRRRR/# )r3   r^   r=   r4   r   r$   )r5   s   "r1   r6   r6   V  s      + 0@ r0   c                    . p\        ^\        V 4      4       FH  p\        W^,
          ,          ^,          W,          ^ ,          4      pVf    R# VP                  V4       KJ  	  V# )ah  Encode every between-interval gap as ``!=`` fragments, or ``None``.

When each gap has an exclusion spelling, the intervals fuse into one
contiguous span (``==1.* | ==3.*`` is ``!=0.*,!=2.*,<4``): the outer
interval across all the bounds plus these exclusions. A gap with no
exclusion spelling makes the bounds a disjoint union, which no single
set expresses.
N)r   rE   r  rG   )r^   r  indexgaps   &   r1   _encode_gapsr  V  s[     Jq#f+&&+A.a0@A;#	 ' r0   c                    V ^8  d   QhRRRR/# r]   r$   )r5   s   "r1   r6   r6   j  s      $8 =Q r0   c                   V R,          w  rVP                   p\        V\        4      '       d[   VP                  '       gI   VP                  '       g7   VP
                  f)   \        VP                  ^ R7      RR7      p. V RR OW3N5# V # )a  Snap the range's final upper out of the pre-release band ``False`` drops.

An exclusive upper at a final ``V`` admits the versions in ``[V.dev0, V)`` at
the bounds level, but a ``prereleases=False`` policy filters them all out, so
it accepts the same releases as ``<V`` (upper at ``V.dev0``). Snapping it lets
:meth:`VersionRange.to_specifier_set` reach the ``<V`` spelling.

Only the last interval's upper is snapped, the one that gives a terser outer
bound. Inner uppers are left alone: snapping one turns its gap to the next
interval into a ``.dev0`` wildcard gap, which a far-apart neighbour would blow
up into an unbounded ``!=N.*`` chain. Those shapes recover as ``None`` here,
the same as under ``None`` / ``True``. The snap is conservative (it skips
boundary, pre-release, and local uppers); the caller keeps it only when it
stays release-equivalent, so an unsnapped shape falls back to the exact form.
Nrg   Frt   rC   )rH   ra   r   rI   is_prereleaser   r   rj   )r^   rO   rP   rH   s   &   r1   _tighten_no_prereleasesr  j  s{      ":LEmmG7G$$%%%MM!7..1.5G--un--Mr0   c                     ] tR tRt$ RtR_tR	]R&   R
]R&   R]R&   R]R&   R	]R&   R]R&   R R lt]]	! 4       ]	! 4       R3RR^RR/R R lll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!R/R" R# ll4       t]R$R%R!R/R& R' ll4       t]R!R/R( R) ll4       tR* R+ ltR, R- ltR. R/ ltR0 R1 ltR2 R3 ltR4 R5 ltR6 R7 ltR8 R9 ltR: R; ltR< R= ltR> R? ltR@ RA ltRB RC lt RD RE lt!]"PF                  R`RF RG ll4       t$]"PF                  R`RH RI ll4       t$RaRJ RK llt$RL RM lt%]RN RO l4       t&RP RQ lt'](RR RS l4       t)RaRT RU llt*RV RW lt+RX RY lt,RZ R[ lt-R\ R] lt.R^t/R# )br   i  aO  A set of :class:`~packaging.version.Version` values accepted by a
:class:`~packaging.specifiers.SpecifierSet`.

Construct via :meth:`~packaging.specifiers.SpecifierSet.to_range`, or with
the :meth:`full`, :meth:`empty`, and :meth:`singleton` class methods.
Compose with :meth:`intersection`, :meth:`union`, :meth:`complement`, and
:meth:`difference` (or the ``&`` / ``|`` / ``~`` / ``-`` operators). Test
membership with ``in`` or :meth:`contains`, filter an iterable with
:meth:`filter`, and convert back to a
:class:`~packaging.specifiers.SpecifierSet` with :meth:`to_specifier_set`.

The configured pre-release policy of the originating specifier set carries
onto the range and controls whether pre-releases are admitted under ``in``,
:meth:`contains`, and :meth:`filter`. With no configured policy,
:meth:`filter` also admits pre-releases in the autodetected opt-in region
(the versions a pre-release-naming specifier asked for). Set algebra keeps
that opt-in scoped to those versions, so unrelated pre-releases are not
admitted wholesale.

:meth:`intersection`, :meth:`union`, :meth:`difference`, and the
:meth:`is_subset` / :meth:`is_superset` / :meth:`is_disjoint` predicates
require both operands to share the same configured policy.

>>> r = SpecifierSet(">=1.0,<2.0").to_range()
>>> "1.5" in r
True
>>> "2.0" in r
False
>>> SpecifierSet(">=2.0,<1.0").to_range().is_empty
True

PEP 440's ``===`` operator matches a candidate string verbatim
(case-insensitive) rather than a set of versions. Ranges built from
``===`` specifiers still support membership, set operations, and conversion
back to a :class:`~packaging.specifiers.SpecifierSet`; matching follows the
literal-equality rule. A ``===`` literal that names a pre-release is
admitted under the default policy by both :meth:`contains` and
:meth:`filter`, since it was named outright.

.. versionadded:: 26.3
_admit_admit_arbitrary_bounds_pre_region_prereleases_configured_rejectr_   r|   frozenset[str]bool | Nonec               $    V ^8  d   QhRRRRRR/# )r3   argsobjectkwargsr4   r   r$   )r5   s   "r1   r6   VersionRange.__annotate__  s!     
 
F 
f 
 
r0   c                	    \        R 4      h)zcannot create 'VersionRange' instances directly; use SpecifierSet.to_range(), VersionRange.full(), VersionRange.empty(), or VersionRange.singleton() instead)	TypeError)clsr   r"  s   &*,r1   __new__VersionRange.__new__  s    H
 	
r0   F
pre_regionprereleases_configuredNc               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )r3   r^   r_   admitr  rejectr{   r|   r)  r*  r  r4   r   r$   )r5   s   "r1   r6   r#    sP     6 6$6 6 	6
 6 )6 !,6 
6r0   c                 aa \        S4      oV'       d   V'       d	   W#,
          pV'       d   \        VV3R lV 4       4      pV'       d   \        VV3R lV 4       4      p\        P                  V 4      pSVn        W'n        W7n        SVn        Wgn        Vf	   V'       g
   RVn	        V# \        \        \        V4      S4      4      Vn	        V# )a  Internal factory; bypasses :meth:`__new__`.

Canonicalizes the bounds so equal version sets share one representation,
then drops admit literals the bounds already admit and reject literals
the bounds do not match anyway. Reject wins over admit on overlap. The
pre-release policy is set here and never reassigned afterwards;
``pre_region`` is canonicalized like the bounds and clipped to them,
or dropped when a configured policy makes it inert.
c              3  R   <"   T F  p\        SSV4      '       d   K  Vx  K  	  R # 5ir8   r   r   r}   r{   r^   s   & r1   r   &VersionRange._build.<locals>.<genexpr>  s&      $G%fowG $   '
'c              3  R   <"   T F  p\        SSV4      '       g   K  Vx  K  	  R # 5ir8   r0  r1  s   & r1   r   r2    s&      %G!&/7C %r3  r$   )ry   	frozensetr!  r'  r  r  r  r  r  r  ru   r   )r&  r^   r,  r-  r{   r)  r*  instances   &f&&f$$ r1   _buildVersionRange._build  s    ( v&VNE $ E
  % F >>#&!!$3!+A( "-Z#%H  	 $) z!:FC$H  r0   c                   V ^8  d   QhRR/# r3   r4   r|   r$   )r5   s   "r1   r6   r#  %  s     7 7t 7r0   c                	f    \        V P                  4      ;'       g    \        V P                  4      # r8   )r|   r  r  selfs   &r1   _has_literalsVersionRange._has_literals%  s"    DKK 66D$66r0   c                   V ^8  d   QhRR/# r:  r$   )r5   s   "r1   r6   r#  (  s     D D4 Dr0   c                P    V P                   ;'       d    V P                  \        8H  # )aK  True when ``_admit_arbitrary`` actually admits non-version strings.

The flag rides through set algebra but only fires admission on full
bounds. Intersection and difference drop it when the bounds shrink, so
away from full bounds it survives only on empty-bounds ranges, where
it keeps ``~~full() == full()`` and union idempotent.
)r  r  r   r<  s   &r1   _arbitrary_activeVersionRange._arbitrary_active(  s!     $$CC)CCr0   c                   V ^8  d   QhRR/# r:  r$   )r5   s   "r1   r6   r#  2  s     
 
4 
r0   c                    V P                  4       '       * ;'       d(    V P                  '       * ;'       d    V P                  RJ# )zTrue when membership is decided by ``_bounds`` alone, enabling the
bounds-only fast paths in :meth:`is_subset` and :meth:`is_disjoint`.
F)r>  r  r  r<  s   &r1   	_is_plainVersionRange._is_plain2  sF    
 ""$$ : :))): :,,E9	
r0   c                    V ^8  d   QhRRRR/# )r3   otherr   r4   Noner$   )r5   s   "r1   r6   r#  <  s     	 	, 	4 	r0   c                    \        V\        4      '       g"   \        R\        V4      P                   24      hV P
                  VP
                  8w  d(   \        RV P
                  : RVP
                  : 24      hR# )z<Refuse combining ranges with different pre-release policies.zexpected VersionRange, got zJCannot combine VersionRange operands with different pre-release policies: z and N)ra   r   r%  typer%   r  
ValueErrorr=  rI  s   &&r1   _check_policy_compat!VersionRange._check_policy_compat<  s|    %..9$u+:N:N9OPQQ''5+H+HH))-)E)E(H I4479  Ir0   c                    V ^8  d   QhRRRR/# )r3   rI  r   r4   r_   r$   )r5   s   "r1   r6   r#  G  s     I IL I5I Ir0   c                    VP                   '       g   V P                   # V P                   '       g   VP                   # \        \        V P                   VP                   4      4      # )zUnion of ``self`` and ``other``'s opt-in regions.

Used by :meth:`union` and :meth:`intersection`; :meth:`_build` clips the
merge to the result bounds. A configured operand carries an empty region,
so it contributes nothing to the merge.
)r  ru   rV   rN  s   &&r1   _merged_regionVersionRange._merged_regionG  sT        ###$$$ ]4#3#3U5F5FGHHr0   c               $    V ^8  d   QhRRRRRR/# )r3   r)  r_   
configuredr  r4   r   r$   )r5   s   "r1   r6   r#  Y  s$     
 
1
?J
	
r0   c          	         V P                  V P                  V P                  V P                  V P                  VVR7      # )zFA structural copy of this range carrying the given pre-release policy.r,  r-  r{   r)  r*  )r7  r  r  r  r  )r=  r)  rV  s   &$$r1   _with_policyVersionRange._with_policyY  s>     {{LL++<< 11!#-  
 	
r0   prereleasesc                    V ^8  d   QhRRRR/# )r3   r[  r  r4   r   r$   )r5   s   "r1   r6   r#  g  s     B B; B, Br0   c               (    V P                  RVR7      # )zReturn the empty range. No version satisfies it.

>>> VersionRange.empty().is_empty
True
>>> "1.0" in VersionRange.empty()
False
r*  r$   )r7  )r&  r[  s   &$r1   emptyVersionRange.emptyf  s     zz"[zAAr0   r{   Tc               $    V ^8  d   QhRRRRRR/# )r3   r{   r|   r[  r  r4   r   r$   )r5   s   "r1   r6   r#  r  s$     
 
!%
;F
	
r0   c               2    V P                  \        VVR7      # )a  Return the full range. Every PEP 440 version satisfies it.

``admit_arbitrary=False`` restricts the range to PEP 440 versions only
(matching the same versions as ``SpecifierSet(">=0.dev0").to_range()``);
its complement is :meth:`empty`. The flag propagates through set algebra
and is part of equality. Default ``True`` so that ``r & full()``
preserves ``r``'s own flag structurally.

>>> "1.0" in VersionRange.full()
True
>>> "wat" in VersionRange.full()
True
>>> "wat" in VersionRange.full(admit_arbitrary=False)
False
)r{   r*  )r7  r   )r&  r{   r[  s   &$$r1   fullVersionRange.fullq  s#    & zz+#.  
 	
r0   c               $    V ^8  d   QhRRRRRR/# )r3   rH   Version | strr[  r  r4   r   r$   )r5   s   "r1   r6   r#    s$     
 
#
5@
	
r0   c                   \        V\        4      '       g   \        V4      p\        VR4      p\        VR4      pV P	                  \        W4334      VR7      # )a  Return the strict singleton range ``{version}``.

Built as the closed interval ``[version, version]`` with strict
equality. ``Specifier("==V")`` matches ``V+local`` too, so the strict
singleton is narrower:

>>> "1.0+local" in VersionRange.singleton("1.0")
False
>>> "1.0+local" in SpecifierSet("==1.0").to_range()
True

:raises packaging.version.InvalidVersion: if version is a string that
    does not parse as a PEP 440 version.
Tr^  )ra   r   r   r   r7  rb   )r&  rH   r[  rO   rP   s   &&$  r1   	singletonVersionRange.singleton  s[    $ '7++g&G7D)7D) zzun./#.  
 	
r0   c                    V ^8  d   QhRRRR/# r3   rI  r   r4   r$   )r5   s   "r1   r6   r#    s     '
 '
, '
< '
r0   c           	        V P                  V4       V P                  p\        \        V P                  VP                  4      4      pV P                  V4      pV P                  ;'       d     VP                  ;'       d    \        V4      pV P                  4       '       g,   VP                  4       '       g   V P                  VVVVR7      # V P                  VV\        P                  VVVR7      # )a=  Range containing exactly the versions in both self and other.

Both operands must share the same configured pre-release policy;
otherwise :exc:`ValueError` is raised.

>>> a = SpecifierSet(">=1.0").to_range()
>>> b = SpecifierSet("<2.0").to_range()
>>> a.intersection(b) == SpecifierSet(">=1.0,<2.0").to_range()
True
r{   r)  r*  opr{   r)  r*  )rO  r  ru   r   r  rS  r  r|   r>  r7  _combine_literalsr#   r,   r=  rI  rV  
new_bounds
new_regioncombined_arbs   &&    r1   intersectionVersionRange.intersection  s     	!!%(11
+DLL%--HI
((/
 !!QQe&<&<QQjAQ 	 !!##E,?,?,A,A;; ,%'1	    %%""(!#- & 
 	
r0   c                    V ^8  d   QhRRRR/# rk  r$   )r5   s   "r1   r6   r#    s     -
 -
< -
L -
r0   c           	        V P                  V4       V P                  p\        \        V P                  VP                  4      4      pV P                  V4      pV'       d\   V P                  ;'       d    \        V P                  4      ;'       g*    VP                  ;'       d    \        VP                  4      pM V P                  ;'       g    VP                  pV P                  4       '       g,   VP                  4       '       g   V P                  VVVVR7      # V P                  VV\        P                  VVVR7      # )a:  Range containing every version in self or other.

Both operands must share the same configured pre-release policy;
otherwise :exc:`ValueError` is raised.

>>> a = VersionRange.singleton("1.0")
>>> b = VersionRange.singleton("2.0")
>>> "1.0" in a.union(b) and "2.0" in a.union(b)
True
>>> "1.5" in a.union(b)
False
rm  rn  )rO  r  ru   rV   r  rS  r  r|   r>  r7  rp  r#   r-   rq  s   &&    r1   unionVersionRange.union  s    	!!%(11
=u}}EF
((/

  11HHd4<<6H  &&>>4+> 
  00JJE4J4JL!!##E,?,?,A,A;; ,%'1	    %%||(!#- & 
 	
r0   c                   V ^8  d   QhRR/# r3   r4   r   r$   )r5   s   "r1   r6   r#    s      
  
L  
r0   c           	         V P                  \        \        V P                  4      4      V P                  V P
                  V P                  RV P                  R7      # )al  Range containing every version not in self.

Preserves the configured pre-release policy. On the version set, double
negation holds for a range with no ``===`` literals (the arbitrary-string
flag round-trips, so ``~~full() == full()``); for ``===`` ranges
complement is one-way. The opt-in region is not restored (see below).

The opt-in region is dropped: a complement is an exclusion, and an
exclusion expresses no pre-release preference. This is what lets
``a & ~b`` shed ``b``'s opt-in, so an excluded ``b`` never force-admits a
pre-release into the result. Complement stays involutive on the version
set, but not on the opt-in region: ``~~r`` covers the same versions as
``r`` yet force-admits none of its pre-releases.

>>> r = SpecifierSet(">=1.0").to_range()
>>> "0.5" in r.complement()
True
>>> "1.5" in r.complement()
False
>>> r.complement().complement() == r
True
rX  r$   )r7  ru   r[   r  r  r  r  r  r<  s   &r1   
complementVersionRange.complement  sO    2 {{$T\\23,,;; 11#'#?#?  
 	
r0   c                    V ^8  d   QhRRRR/# rk  r$   )r5   s   "r1   r6   r#  #  s     ?
 ?
 ?
 ?
r0   c           	     D   V P                  V4       VP                  '       g   VP                  '       g   V # \        \	        V P                  \        VP                  4      4      4      pRpV P                  f   V P                  pV P                  ;'       d    W P                  8H  pV P                  4       '       g6   VP                  4       '       g    V P                  VVVV P                  R7      # V P                  VV\        P                  VVV P                  R7      # )a  Range containing the versions in self but not in other.

Matches ``self & ~other`` on the version set and the opt-in region;
``other`` acts as a bounds-only exclusion that grants no opt-in. The
arbitrary-string flag survives only when ``other`` removed no versions:
a difference that shrinks the bounds forgets it, as ``self & ~other``
would, so no later widening union can revive it. They still part on
``===`` literals, whose complement is one-way: a ``===`` literal stays
when ``self`` admits it and ``other`` does not. Both operands must
share the same configured pre-release policy (as :meth:`intersection`
and :meth:`union` require); otherwise :exc:`ValueError` is raised.
``a - empty()`` returns a range equal to ``a``.

>>> a = SpecifierSet(">=1.0").to_range()
>>> b = SpecifierSet(">=2.0").to_range()
>>> "1.5" in a.difference(b)
True
>>> "2.0" in a.difference(b)
False
>>> a.difference(VersionRange.empty()) == a
True
rm  rn  r$   )rO  r  r  ru   r   r[   r  r  r  r>  r7  rp  r#   r.   )r=  rI  rr  rs  rt  s   &&   r1   
differenceVersionRange.difference#  s   . 	!!%( }}}U\\\K T\\+=emm+LM

 ,.
''/))J ,,KK||1K!!##E,?,?,A,A;; ,%'+'C'C	    %%  (!#'#?#? & 
 	
r0   c               4    V ^8  d   QhRRRRRRRRR	RR
RRR/# )r3   rI  r   rr  r_   ro  r#   r{   r|   r)  r*  r  r4   r$   )r5   s   "r1   r6   r#  d  sP     &
 &
&
 )&

 &
 &
 )&
 !,&
 
&
r0   c          	     J   \        4       p\        4       pV P                  V P                  ,          VP                  ,          VP                  ,           F  p	V P                  V	4      p
VP                  V	4      pV\        P
                  J d   T
;'       d    TpM2V\        P                  J d   T
;'       g    TpMT
;'       d    V'       * pV'       d   VP                  V	4       K  VP                  V	4       K  	  V P                  V\        V4      \        V4      VVVR7      # )zGResolve admit/reject for ``self`` ``op`` ``other`` over their literals.rX  )
setr  r  _matches_literalr#   r,   r-   addr7  r5  )r=  rI  rr  ro  r{   r)  r*  admitsrejectsr}   self_inother_inwants   &&&$$$$      r1   rp  VersionRange._combine_literalsd  s     5E {{T\\1ELL@5==PPG++G4G--g6HV(((++8v||#**(//x<

7#G$ Q  {{F#W%+!#9  
 	
r0   c                    V ^8  d   QhRRRR/# )r3   r}   r~   r4   r|   r$   )r5   s   "r1   r6   r#    s     
9 
9 
9 
9r0   c                    WP                   9   d   R# WP                  9   d   R# \        V4      pVf   V P                  4       # \	        V P
                  V4      # )z=Whether literal (case-folded) matches this range's predicate.FT)r  r  r   rB  r   r  )r=  r}   r   s   && r1   r  VersionRange._matches_literal  sK    ll"kk!(>))++"4<<88r0   c                    V ^8  d   QhRRRR/# r3   rI  r!  r4   r   r$   )r5   s   "r1   r6   r#    s     ( (V ( (r0   c                \    \        V\        4      '       g   \        # V P                  V4      # )z(Operator alias for :meth:`intersection`.)ra   r   NotImplementedru  rN  s   &&r1   __and__VersionRange.__and__  s&    %..!!  ''r0   c                    V ^8  d   QhRRRR/# r  r$   )r5   s   "r1   r6   r#    s     ! !F !| !r0   c                \    \        V\        4      '       g   \        # V P                  V4      # )z!Operator alias for :meth:`union`.)ra   r   r  ry  rN  s   &&r1   __or__VersionRange.__or__  s$    %..!!zz%  r0   c                   V ^8  d   QhRR/# r|  r$   )r5   s   "r1   r6   r#    s     ! !L !r0   c                "    V P                  4       # )z&Operator alias for :meth:`complement`.)r~  r<  s   &r1   
__invert__VersionRange.__invert__  s      r0   c                    V ^8  d   QhRRRR/# r  r$   )r5   s   "r1   r6   r#    s     & &V & &r0   c                \    \        V\        4      '       g   \        # V P                  V4      # )z&Operator alias for :meth:`difference`.)ra   r   r  r  rN  s   &&r1   __sub__VersionRange.__sub__  s$    %..!!u%%r0   c                    V ^8  d   QhRRRR/# r3   rI  r   r4   r|   r$   )r5   s   "r1   r6   r#    s     !/ !/| !/ !/r0   c                j   V P                  V4       V P                  4       '       d   VP                  4       '       g   R# V P                  4       '       dE   VP                  4       '       d/   \        V P                  \        VP                  4      4      '       * # V P                  V4      P                  # )aP  Return whether every member of self is also a member of other.

On versions and ``===`` literals this is
``self.difference(other).is_empty``: subtracting other leaves nothing
behind. A live arbitrary admission (the flag at full bounds) is only a
subset of another live one.

Both operands must share the same configured pre-release policy;
otherwise :exc:`ValueError` is raised.

>>> inner = SpecifierSet(">=1.5,<1.8").to_range()
>>> outer = SpecifierSet(">=1.0,<2.0").to_range()
>>> inner.is_subset(outer)
True
>>> outer.is_subset(inner)
False
>>> VersionRange.empty().is_subset(outer)
True
F)rO  rB  rF  r   r  r[   r  is_emptyrN  s   &&r1   	is_subsetVersionRange.is_subset  s    ( 	!!%( !!##E,C,C,E,E >> 1 1'6H6WXXX u%...r0   c                    V ^8  d   QhRRRR/# r  r$   )r5   s   "r1   r6   r#    s     % % %$ %r0   c                F    V P                  V4       VP                  V 4      # )ak  Return whether every member of other is also a member of self.

The mirror of :meth:`is_subset`: ``a.is_superset(b)`` is
``b.is_subset(a)``.

Both operands must share the same configured pre-release policy;
otherwise :exc:`ValueError` is raised.

>>> outer = SpecifierSet(">=1.0,<2.0").to_range()
>>> outer.is_superset(SpecifierSet(">=1.5,<1.8").to_range())
True
)rO  r  rN  s   &&r1   is_supersetVersionRange.is_superset  s!     	!!%(t$$r0   c                    V ^8  d   QhRRRR/# r  r$   )r5   s   "r1   r6   r#    s     1 1 1$ 1r0   c                    V P                  V4       V P                  4       '       d<   VP                  4       '       d&   \        V P                  VP                  4      '       * # V P	                  V4      P
                  # )ap  Return whether self and other share no member.

Equivalent to ``(self & other).is_empty``.

Both operands must share the same configured pre-release policy;
otherwise :exc:`ValueError` is raised.

>>> a = SpecifierSet(">=1.0,<2.0").to_range()
>>> a.is_disjoint(SpecifierSet(">=2.0,<3.0").to_range())
True
>>> a.is_disjoint(SpecifierSet(">=1.5,<2.5").to_range())
False
)rO  rF  r   r  ru  r  rN  s   &&r1   is_disjointVersionRange.is_disjoint  s\     	!!%( >> 1 1'emmDDD  '000r0   c                    V ^8  d   QhRRRR/# r  r$   )r5   s   "r1   r6   r#    s     S SL ST Sr0   c                ~    V P                  V4      P                  ;'       d    VP                  V 4      P                  # )aZ  Whether self and other admit the same non-pre-release versions.

Used by :meth:`to_specifier_set` under a ``prereleases=False`` policy,
where pre-releases are unobservable: the symmetric difference is empty
exactly when the two ranges accept the same releases. Both operands
carry that policy, so the difference below reads emptiness through it.
)r  r  rN  s   &&r1   _same_releasesVersionRange._same_releases  s2     u%..RR53C3CD3I3R3RRr0   c               (    V ^8  d   QhRRRRRRRR/# )	r3   iterablezIterable[UnparsedVersionVar]r[  r  keyrJ  r4   zIterator[UnparsedVersionVar]r$   )r5   s   "r1   r6   r#    s2     + +.+ !+ 	+
 
&+r0   c                	    R # r8   r$   r=  r  r[  r  s   &&&&r1   filterVersionRange.filter  s     (+r0   c               (    V ^8  d   QhRRRRRRRR/# )	r3   r  zIterable[T]r[  r  r  zCallable[[T], UnparsedVersion]r4   zIterator[T]r$   )r5   s   "r1   r6   r#  
  s2       ! ,	
 
r0   c                	    R # r8   r$   r  s   &&&&r1   r  r  	  s     r0   c               (    V ^8  d   QhRRRRRRRR/# )	r3   r  Iterable[Any]r[  r  r  %Callable[[Any], Version | str] | Noner4   Iterator[Any]r$   )r5   s   "r1   r6   r#    s2     (
 (
(
 !(
 3	(

 
(
r0   c                h   RpVf   V P                   pV P                  pV P                  4       pV P                  '       ga   V P                  '       gO   V'       gG   V'       d(   W@P
                  8X  d   \        V P
                  WR4      # \        V P
                  WW$4      # V P                  WW%V4      # )a  Yield items from iterable whose version falls inside the range.

With prereleases ``None`` the PEP 440 default applies: pre-releases are
buffered and only emitted if no final release in iterable is in range,
except that a pre-release inside the autodetected opt-in region, or named
outright by a ``===`` literal, is force-admitted in place (as
``prereleases=True`` would yield it). A flushed buffer comes after
every in-place yield, so the output is not version-sorted.

The signature mirrors
:meth:`~packaging.specifiers.SpecifierSet.filter`.

>>> r = SpecifierSet(">=1.0,<2.0").to_range()
>>> list(r.filter(["0.9", "1.5", "2.0"]))
['1.5']
Tr$   )r  r  rB  r  r  r  r   _filter_with_admission)r=  r  r[  r  regionarbitrary_actives   &&&&  r1   r  r    s    , (* 66K%%F113{{{4<<<8H
 &LL0'hTJJ#DLL(UU**;&
 	
r0   c               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r3   r  r  r  r  r[  r  r  r|   r  r_   r4   r  r$   )r5   s   "r1   r6   r#  ;  sN     U$ U$U$ 3U$ !	U$
 U$ %U$ 
U$r0   c              #    a aaaa"   S P                   oS P                  oR VVVVV 3R llpVRJ d&   V F  pV! V4      w  p p	V'       g   K  Vx  K  	  R# VRJ d=   V F4  pV! V4      w  rp	V'       g   K  V
e   V
P                  '       d   K0  Vx  K6  	  R# . p. pRpV F  pV! V4      w  rpV'       g   K  V
f2   V'       d   Vx  M"VP                  V4       VP                  V4       KM  V
P                  '       g+   V'       g   T Rj  xL
  VP	                  4        RpVx  K  V'       g   V'       d   \        WZ4      '       d   Vx  K  V'       d   K  VP                  V4       K  	  V'       g   T Rj  xL
  R# R#  Lx L
5i)z~Filter for ranges with admit/reject literals or live arbitrary
admission (including the universal ``SpecifierSet("")`` range).c                    V ^8  d   QhRRRR/# )r3   itemr   r4   z!tuple[bool, Version | None, bool]r$   )r5   s   "r1   r6   9VersionRange._filter_with_admission.<locals>.__annotate__H  s     	' 	' 	' A 	'r0   c                  < Sf   T MS! V 4      p\        V4      P                  4       pS'       d
   VS9   d   R# S'       d   VS9   d   R\        V4      R3# \        V4      pVf   SR R3# \        SP                  V4      '       g   R# RVR3# )NFT)FNF)r~   rO   r   r   r  )	r  raw	raw_lowerr   	admit_setr  r  
reject_setr=  s	   &   r1   r,  2VersionRange._filter_with_admission.<locals>.admitH  s    ),#d)CC(Ii:5))Y)3^C0$66#C(F~'u44&t||V<<))&&r0   TNF)r  r  r  rF   clearr   )r=  r  r  r[  r  r  r,  r  ok_r   all_nonfinalarbitrary_stringsfound_final
by_literalr  r  s   f&f&f&         @@r1   r  #VersionRange._filter_with_admission;  sp     KK	\\
	' 	'" $  ;Aq2J ! %  %dA%&*>*>*>
 !  #%')D%*4["B
~J%,,T2 ''-'''"000%++-"&K

 f)<V)L)L
;##D); > ### ! 1" $sZ   AF?F7F:FF	FF#F3F;FF9F>F	?	F	Fc                    V ^8  d   QhRRRR/# )r3   specifier_setr   r4   r   r$   )r5   s   "r1   r6   r#    s     *
 *
 *
 *
r0   c           	     *   V'       g   V P                  4       pMVP                  '       g4   V P                  \        \	        VP                  4       4      4      R7      pMV P                  4       pV F  pVP                  R8X  d7   V P                  R\        VP                  P                  4       04      R7      pM2V P                  \        \	        VP                  4       4      4      R7      pVP                  V4      pK  	  . pVP                  f^   V FW  pVP                  R8w  g   K  VP                  '       g   K*  \        \	        VP                  4       4      4      p\        WV4      pKY  	  VP                  \	        V4      VP                  R7      # )a9  Build the range accepted by ``specifier_set``.

Friend constructor for :meth:`~packaging.specifiers.SpecifierSet.to_range`.
The intersection of every specifier in the set: an empty set yields the
full range, an unsatisfiable set yields the empty range, and ``===``
specifiers contribute literal-string admission.
)r^   ===)r^   r,  )r)  rV  r$   )rc  _has_arbitraryr7  rb   ru   _get_rangesoperatorr5  rH   rO   
_to_rangesru  _prereleasesr[  rV   rY  )r&  r  rZ   specoperandr  spec_boundss   &&     r1   _from_specifier_set VersionRange._from_specifier_set  sP    XXZF---ZZ'm.G.G.I(JK   F XXZF%==E)!jj!DLL4F4F4H3I)J ) G "jj/doo6G0HI ) G  ,,W5 & "$%%-%==E)d.>.>.>"259J3K"LK*6?F	 & ""V}$11 # 
 	
r0   c                   V ^8  d   QhRR/# )r3   r4   zSpecifierSet | Noner$   )r5   s   "r1   r6   r#    s     O O"5 Or0   c                d   ^RI HpHp V P                  pV P                  '       d   R# V P
                  '       d   V P                  \        8w  d   R# V P                  '       d   V! RVR7      # V P                  '       g3   \        V P                  4      ^8w  d   R# V P                  w  pRV 2.pEMV P                  '       d   R# V P                  \        8X  d   V P
                  '       d   RMR.pMV P                  .pVRJ d7   \        V P                  4      pWpP                  8w  d   VP                  V4       . pV F|  p\        V4      p	V	f   K  R Fb  p
\        V^ ,          ^ ,          VR,          ^,          V
4      pVf   K2  R	P                  W,           4      pW9  g   KQ  VP                  V4       Kd  	  K~  	  VRJ ;'       d    V P                   V P                  8H  pRpRpV F  pV.pV'       d   TP                  V'       d   V R
2MR4       V F  p V! VVR7      p\        T4      \        \#        T4      4      3pTe
   TT8  d   K:  TP%                  4       pTT 8H  ;'       g    TRJ ;'       d    T P'                  T4      pT'       g   K~  TTrK  	  K  	  V#   T d     K  i ; i)a  Return a :class:`~packaging.specifiers.SpecifierSet` matching the same
versions as self, or ``None`` if no single set expresses it.

PEP 440 has no syntax for the strict singleton ``{V}`` (an exclusive
plain-version bound), a disjoint union of two or more intervals, or a
partial pre-release opt-in region, so ranges built by set algebra often
return ``None``. A gap that takes more than ``_MAX_EXCLUSION_RUN``
contiguous ``!=`` exclusions to spell returns ``None`` too,
rather than a pathologically long chain; reaching that cap takes either
set algebra or a specifier set that already spells the gap out with
over a hundred contiguous ``!=N.*`` exclusions. An empty range maps to
``SpecifierSet("<0")``, unless it still carries the arbitrary-string
flag (which no set reproduces), and a full range that admits arbitrary
strings maps to ``SpecifierSet("")``.

A range built from a :class:`~packaging.specifiers.SpecifierSet`
re-encodes, short of that exclusion cap. The result is the simplest
candidate whose own
:meth:`~packaging.specifiers.SpecifierSet.to_range` reproduces self
exactly (bounds, ``===`` literals, and the opt-in region are all part of
equality), so it filters the same versions. Two cases relax that
exactness without changing what is filtered: an empty range recovers as
the canonical empty range (same versions, none, but not self's bounds),
and under a ``prereleases=False`` policy the result need only match self's
releases, so ``(-inf, 3.14)`` recovers as the tighter ``<3.14`` rather
than ``!=3.14,<=3.14``.

Each call encodes a handful of candidate spellings and keeps the
simplest one that verifies, where verifying means parsing the candidate
and round-tripping it through
:meth:`~packaging.specifiers.SpecifierSet.to_range`. The work grows
with the number of intervals and exclusions in the range, and the
result is not cached, so convert once and reuse the returned set rather
than converting per candidate version in a hot loop.

>>> str(SpecifierSet(">=1.0,<2.0").to_range().to_specifier_set())
'<2.0,>=1.0'
>>> str(SpecifierSet("==1.0").to_range().to_specifier_set())
'==1.0'
>>> VersionRange.singleton("1.5").to_specifier_set() is None
True
)InvalidSpecifierr   Nz<0)r[  r   z>=0.dev0F,z	,>=0.dev0)FTrC   )r   r   )
specifiersr  r   r  r  r  r  r   r  rE   r  r  rF   r  r   r   r  r~   to_ranger  )r=  r  r   rV  r}   baseslayouts	tightenedlayoutr  r   outerrp   	add_floorbestbest_key
candidatesspec_str	recoveredr  rm   matchess   &                     r1   to_specifier_setVersionRange.to_specifier_set  sn   V 	?11
<<<   T\\Z%?===  *==|||4;;1$JW7)_%E[[[\\Z'000RjAE ||nGU"3DLLA	,NN9- E!)&1
%!.I,VAYq\6":a=)TE} 88E$67D(T* "/ "" $&KK4+;+;t||+K	 %)DJ!!TF)"4*M& ,X: NI 9~s3y>':;#x &..0	#t+  %'JJD,?,?	,J  7%.(1 ' > % ( s   
J$$J/.J/c                   V ^8  d   QhRR/# r:  r$   )r5   s   "r1   r6   r#  Q  s     Q Q$ Qr0   c                2   V P                  4       '       d   R# V P                  RJ pV P                   F/  pV'       d$   \        V4      pVe   VP                  '       d   K.   R# 	  V P
                  '       g   R# T;'       d    \        V P
                  4      # )a  ``True`` if no version or string satisfies this range.

Agrees with :meth:`~packaging.specifiers.SpecifierSet.is_unsatisfiable`,
including the pre-release policy: a range whose only members are
pre-releases is empty when that policy excludes them.

>>> SpecifierSet(">=2,<1").to_range().is_empty
True
>>> SpecifierSet(">=1,<2").to_range().is_empty
False
>>> SpecifierSet("==1.0a1", prereleases=False).to_range().is_empty
True
FT)rB  r  r  r   r  r  r   )r=  excludes_prereleasesr}   r   s   &   r1   r  VersionRange.is_emptyP  s    " !!###;;uD{{G#'0%&*>*>*> # |||#PP(B4<<(PPr0   c               (    V ^8  d   QhRRRRRRRR/# )r3   r  rf  r[  r  	installedr4   r|   r$   )r5   s   "r1   r6   r#  q  s8     D7 D7D7 !D7 	D7
 
D7r0   c                ,   \        V\        \        34      '       g"   \        R\	        V4      P
                   24      h\        V\        4      '       d   TMRpV'       d   Vf   \        V4      pV'       d   Ve   VP                  '       d   RpVf   V P                  MTpV P                  '       g   V P                  '       dg   \        V4      P                  4       pW`P                  9   d   R# W`P                  9   d,   VRJ d$   \        V4      pVe   VP                  '       d   R# R# \        V\        4      '       g&   Vf   \        V4      pVf   V P                  4       # TpVRJ d   VP                  '       d   R# \        V P                  V4      # )a  Return whether item is contained in this range.

:param item: a version string or :class:`~packaging.version.Version`.
:param prereleases: whether to match pre-releases. ``None`` (default)
    uses the range's own policy.
:param installed: when ``True``, accept a pre-release item even if the
    range would not otherwise allow it.

Unlike :meth:`filter`, this does not consult the autodetected pre-release
opt-in region; it reads only the configured policy. This mirrors
:meth:`~packaging.specifiers.SpecifierSet.contains` versus
:meth:`~packaging.specifiers.SpecifierSet.filter`.

Unparsable strings do not match, except where the full
``SpecifierSet`` would also match: the full range admits any string,
and a ``===`` range admits items equal to the literal
case-insensitively.

>>> r = SpecifierSet(">=1.0,<2.0").to_range()
>>> r.contains("1.5")
True
>>> r.contains("2.0")
False

:raises TypeError: if item is not a str or Version.
z5VersionRange.contains() expected str or Version, got NTF)ra   r~   r   r%  rL  r%   r   r  r  r  r  rO   rB  r   r  )r=  r  r[  r  r   effective_preitem_strliteral_parseds   &&&&    r1   containsVersionRange.containsq  sQ   @ $g//Dz**+- 
 *4D')B)B#D)F+0D0D0DK -8,?D(([ 	 ;;;$,,,4y(H<<';;& E)%3H%=N%1n6R6R6R$$((~'-~--//DE!d&8&8&8"4<<66r0   c                    V ^8  d   QhRRRR/# )r3   r  rf  r4   r|   r$   )r5   s   "r1   r6   r#    s     # # #4 #r0   c                $    V P                  V4      # )zReturn whether item is contained in this range.

Forwards to :meth:`contains` with default arguments.

>>> "1.5" in SpecifierSet(">=1.0,<2.0").to_range()
True
)r  )r=  r  s   &&r1   __contains__VersionRange.__contains__  s     }}T""r0   c                    V ^8  d   QhRRRR/# )r3   rI  r!  r4   r|   r$   )r5   s   "r1   r6   r#    s     %
 %
F %
t %
r0   c                   \        V\        4      '       g   \        # V P                  VP                  8H  ;'       d    V P                  VP                  8H  ;'       d}    V P
                  VP
                  8H  ;'       d\    V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P                  VP                  8H  # )a  Structural equality.

Compares the bounds, the ``===`` admit/reject literals, the
arbitrary-string flag, the configured pre-release policy, and the
opt-in region, not just the version set. Keying on the region makes
equality a congruence (equal ranges stay equal under further operations),
so equal implies same :meth:`contains` and :meth:`filter`, but not the
converse: an empty range keeps the flag it was built with, so two empty
ranges need not be equal.

Different specifiers for the same range fold to one canonical form:

>>> SpecifierSet(">1.0a1").to_range() == SpecifierSet(">=1.0a2.dev0").to_range()
True

The opt-in region is part of equality, so ``<=1.0`` (no pre-releases) and
``<1.0.post0.dev0`` (autodetects a ``.dev`` opt-in) cover the same
versions yet compare unequal:

>>> le, lt = SpecifierSet("<=1.0"), SpecifierSet("<1.0.post0.dev0")
>>> le.to_range() == lt.to_range()
False

>>> r = SpecifierSet(">=1.0,<2.0").to_range()
>>> r == SpecifierSet(">=1.0,<2.0").to_range()
True
)	ra   r   r  r  r  r  r  r  r  rN  s   &&r1   __eq__VersionRange.__eq__  s    8 %..!!LLEMM) 6 6u||+6 6-6 6 %%)?)??6 6 ,,0M0MM	6 6
   E$5$55	
r0   c                   V ^8  d   QhRR/# )r3   r4   r   r$   )r5   s   "r1   r6   r#    s     

 

# 

r0   c                	    \        V P                  V P                  V P                  V P                  V P
                  V P                  34      # r8   )hashr  r  r  r  r  r  r<  s   &r1   __hash__VersionRange.__hash__  sD    %%,,  	
 		
r0   c                   V ^8  d   QhRR/# )r3   r4   r~   r$   )r5   s   "r1   r6   r#    s     = =# =r0   c                   . pV P                   '       d%   VP                  \        V P                   4      4       V P                  '       dB   VP                  RRP	                  \        V P                  4      4      ,           R,           4       V'       d   RP	                  V4      MRpV P                  '       d+   V RRP	                  \        V P                  4      4       R2pRpV P                  '       d
   VR,          pV P                  e   VR	V P                   2,          pV P                  '       d!   VR
\        V P                  4      : 2,          pRV P                  P                   RV: V R2# )a  Human-readable representation for debugging.

>>> SpecifierSet(">=1.0,<2.0").to_range()
<VersionRange '[1.0, 2.0.dev0)'>
>>> SpecifierSet("").to_range()
<VersionRange '(-inf, +inf)' arbitrary>
>>> SpecifierSet(">=2.0,<1.0").to_range()
<VersionRange '(empty)'>
{r   }r   z(empty)z \ {r  z
 arbitraryz pre=z pre-region=r    r   )r  rF   r   r  r   sortedr  r  r  r  	__class__r%   )r=  r   bodyr   s   &   r1   __repr__VersionRange.__repr__  s*    <<<LL*4<<89;;;LLtyy)<==CD$)uzz% y <<<V6$))F4<<,@"A!B"ED    L D''3eD889::Dl#4T5E5E#F"IJJD4>>**+1THTF!<<r0   r$   )r  r  r  r  r  r  )N.)NN)0r%   r&   r'   r(   r)   	__slots____annotations__r'  classmethodr5  r7  r>  rB  rF  rO  rS  rY  r_  rc  rh  ru  ry  r~  r  rp  r  r  r  r  r  r  r  r  r  typingoverloadr  r  r  r  propertyr  r  r  r  r  r  r/   r$   r0   r1   r   r     s   (TI "!  
  &% )(
  !*!* %6 ,.6 /36 6p7D
	I$
 B B B 
(,
IM
 
0 
CG
 
<'
R-
^ 
D?
B&
P
9(!!&!/F%"1*S __+ + __ (
TU$n *
 *
XOb Q Q@D7L#%
N

= =r0   )Er)   
__future__r   r*   r#  r   r   r   r   _rangesr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   rH   r   collections.abcr   r   r   r   r   r  r   r9   r   r~   UnparsedVersionr    r   Enumr#   r:   rV   r[   rb   rq   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r$   r0   r1   <module>r+     s+    #       $ FF!( 
CL%1I   TYY 4n%P2&R6/&;;$ *F./b$>"B2jFDA%N:B %	2j@F(:L= L=r0   