@@ -288,6 +288,17 @@ def __repr__(self):
288
288
distribution = self .dist ,
289
289
)
290
290
291
+ def __eq__ (self , other ):
292
+ # type: (Any) -> bool
293
+ if isinstance (other , self .__class__ ):
294
+ return self .name == other .name and self .version == other .version
295
+ return False
296
+
297
+ # Needed for Python 2, which does not implement this by default
298
+ def __ne__ (self , other ):
299
+ # type: (Any) -> bool
300
+ return not self .__eq__ (other )
301
+
291
302
@property
292
303
def name (self ):
293
304
# type: () -> str
@@ -351,6 +362,17 @@ def __repr__(self):
351
362
extras = self .extras ,
352
363
)
353
364
365
+ def __eq__ (self , other ):
366
+ # type: (Any) -> bool
367
+ if isinstance (other , self .__class__ ):
368
+ return self .base == other .base and self .extras == other .extras
369
+ return False
370
+
371
+ # Needed for Python 2, which does not implement this by default
372
+ def __ne__ (self , other ):
373
+ # type: (Any) -> bool
374
+ return not self .__eq__ (other )
375
+
354
376
@property
355
377
def name (self ):
356
378
# type: () -> str
@@ -404,6 +426,10 @@ def __init__(self, py_version_info):
404
426
version_info = sys .version_info [:3 ]
405
427
self ._version = Version ("." .join (str (c ) for c in version_info ))
406
428
429
+ # We don't need to implement __eq__() and __ne__() since there is always
430
+ # only one RequiresPythonCandidate in a resolution, i.e. the host Python.
431
+ # The built-in object.__eq__() and object.__ne__() do exactly what we want.
432
+
407
433
@property
408
434
def name (self ):
409
435
# type: () -> str
0 commit comments