@@ -22,7 +22,11 @@ def __init__(
2222 and not include_max
2323 and not full_max .is_prerelease ()
2424 and not full_max .build
25- and (min is None or not min .is_prerelease () or not min .equals_without_prerelease (full_max ))
25+ and (
26+ min is None
27+ or not min .is_prerelease ()
28+ or not min .equals_without_prerelease (full_max )
29+ )
2630 ):
2731 full_max = full_max .first_prerelease
2832
@@ -105,7 +109,9 @@ def allows_any(self, other: VersionConstraint) -> bool:
105109 return any ([self .allows_any (constraint ) for constraint in other .ranges ])
106110
107111 if isinstance (other , VersionRange ):
108- return not other .is_strictly_lower (self ) and not other .is_strictly_higher (self )
112+ return not other .is_strictly_lower (self ) and not other .is_strictly_higher (
113+ self
114+ )
109115
110116 raise ValueError ("Unknown VersionConstraint type {}." .format (other ))
111117
@@ -160,7 +166,9 @@ def intersect(self, other: VersionConstraint) -> VersionConstraint:
160166 return intersect_min
161167
162168 # If we got here, there is an actual range.
163- return VersionRange (intersect_min , intersect_max , intersect_include_min , intersect_include_max )
169+ return VersionRange (
170+ intersect_min , intersect_max , intersect_include_min , intersect_include_max
171+ )
164172
165173 def union (self , other : VersionConstraint ) -> VersionConstraint :
166174 from .version import Version
@@ -170,19 +178,23 @@ def union(self, other: VersionConstraint) -> VersionConstraint:
170178 return self
171179
172180 if other == self .min :
173- return VersionRange (self .min , self .max , include_min = True , include_max = self .include_max )
181+ return VersionRange (
182+ self .min , self .max , include_min = True , include_max = self .include_max
183+ )
174184
175185 if other == self .max :
176- return VersionRange (self .min , self .max , include_min = self .include_min , include_max = True )
186+ return VersionRange (
187+ self .min , self .max , include_min = self .include_min , include_max = True
188+ )
177189
178190 return VersionUnion .of (self , other )
179191
180192 if isinstance (other , VersionRange ):
181193 # If the two ranges don't overlap, we won't be able to create a single
182194 # VersionRange for both of them.
183- edges_touch = (self . max == other . min and ( self . include_max or other . include_min )) or (
184- self .min == other .max and (self .include_min or other .include_max )
185- )
195+ edges_touch = (
196+ self .max == other .min and (self .include_max or other .include_min )
197+ ) or ( self . min == other . max and ( self . include_min or other . include_max ))
186198
187199 if not edges_touch and not self .allows_any (other ):
188200 return VersionUnion .of (self , other )
@@ -245,14 +257,18 @@ def difference(self, other: VersionConstraint) -> VersionConstraint:
245257 elif self .min == other .min :
246258 before = self .min
247259 else :
248- before = VersionRange (self .min , other .min , self .include_min , not other .include_min )
260+ before = VersionRange (
261+ self .min , other .min , self .include_min , not other .include_min
262+ )
249263
250264 if not self .allows_higher (other ):
251265 after = None
252266 elif self .max == other .max :
253267 after = self .max
254268 else :
255- after = VersionRange (other .max , self .max , not other .include_max , self .include_max )
269+ after = VersionRange (
270+ other .max , self .max , not other .include_max , self .include_max
271+ )
256272
257273 if before is None and after is None :
258274 return EmptyConstraint ()
@@ -345,7 +361,12 @@ def is_adjacent_to(self, other: "VersionRange") -> bool:
345361 if self .max != other .min :
346362 return False
347363
348- return self .include_max and not other .include_min or not self .include_max and other .include_min
364+ return (
365+ self .include_max
366+ and not other .include_min
367+ or not self .include_max
368+ and other .include_min
369+ )
349370
350371 def __eq__ (self , other ):
351372 if not isinstance (other , VersionRange ):
0 commit comments