mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #21481: Teach argparse equality tests to return NotImplemented when comparing to unknown types.
This commit is contained in:
parent
dd5e53a086
commit
dea46ec965
3 changed files with 13 additions and 0 deletions
|
@ -1198,9 +1198,13 @@ class Namespace(_AttributeHolder):
|
|||
setattr(self, name, kwargs[name])
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Namespace):
|
||||
return NotImplemented
|
||||
return vars(self) == vars(other)
|
||||
|
||||
def __ne__(self, other):
|
||||
if not isinstance(other, Namespace):
|
||||
return NotImplemented
|
||||
return not (self == other)
|
||||
|
||||
def __contains__(self, key):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue