@@ -49,6 +49,7 @@ class UndefinedEnvironmentName(ValueError):
4949 "python_implementation" : "platform_python_implementation" ,
5050}
5151
52+ PYTHON_VERSION_MARKERS = ["python_version" , "python_full_version" ]
5253
5354# Parser: PEP 508 Environment Markers
5455_parser = Parser (GRAMMAR_PEP_508_MARKERS , "lalr" )
@@ -259,22 +260,6 @@ def value(self) -> str:
259260
260261 def intersect (self , other : MarkerTypes ) -> MarkerTypes :
261262 if isinstance (other , SingleMarker ):
262- if other .name != self .name :
263- return MultiMarker (self , other )
264-
265- if self == other :
266- return self
267-
268- if self ._operator in {"in" , "not in" } or other .operator in {"in" , "not in" }:
269- return MultiMarker .of (self , other )
270-
271- new_constraint = self ._constraint .intersect (other .constraint )
272- if new_constraint .is_empty ():
273- return EmptyMarker ()
274-
275- if new_constraint == self ._constraint or new_constraint == other .constraint :
276- return SingleMarker (self ._name , new_constraint )
277-
278263 return MultiMarker .of (self , other )
279264
280265 return other .intersect (self )
@@ -416,7 +401,13 @@ def of(cls, *markers: MarkerTypes) -> MarkerTypes:
416401 if isinstance (marker , SingleMarker ):
417402 intersected = False
418403 for i , mark in enumerate (new_markers ):
419- if isinstance (mark , SingleMarker ) and mark .name == marker .name :
404+ if isinstance (mark , SingleMarker ) and (
405+ mark .name == marker .name
406+ or (
407+ mark .name in PYTHON_VERSION_MARKERS
408+ and marker .name in PYTHON_VERSION_MARKERS
409+ )
410+ ):
420411 intersection = mark .constraint .intersect (marker .constraint )
421412 if intersection == mark .constraint :
422413 intersected = True
@@ -560,13 +551,15 @@ def of(cls, *markers: BaseMarker) -> MarkerTypes:
560551 if marker in markers :
561552 continue
562553
563- if isinstance (marker , SingleMarker ) and marker .name == "python_version" :
554+ if (
555+ isinstance (marker , SingleMarker )
556+ and marker .name in PYTHON_VERSION_MARKERS
557+ ):
564558 included = False
565559 for i , mark in enumerate (markers ):
566560 if (
567561 not isinstance (mark , SingleMarker )
568- or isinstance (mark , SingleMarker )
569- and mark .name != marker .name
562+ or mark .name not in PYTHON_VERSION_MARKERS
570563 ):
571564 continue
572565
0 commit comments