diff options
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 45679cf..42f24cd 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -2488,15 +2488,14 @@ class Parameter: return hash((self.name, self.kind, self.annotation, self.default)) def __eq__(self, other): - return (self is other or - (issubclass(other.__class__, Parameter) and - self._name == other._name and - self._kind == other._kind and - self._default == other._default and - self._annotation == other._annotation)) - - def __ne__(self, other): - return not self.__eq__(other) + if self is other: + return True + if not isinstance(other, Parameter): + return NotImplemented + return (self._name == other._name and + self._kind == other._kind and + self._default == other._default and + self._annotation == other._annotation) class BoundArguments: @@ -2610,13 +2609,12 @@ class BoundArguments: self.arguments = OrderedDict(new_arguments) def __eq__(self, other): - return (self is other or - (issubclass(other.__class__, BoundArguments) and - self.signature == other.signature and - self.arguments == other.arguments)) - - def __ne__(self, other): - return not self.__eq__(other) + if self is other: + return True + if not isinstance(other, BoundArguments): + return NotImplemented + return (self.signature == other.signature and + self.arguments == other.arguments) def __setstate__(self, state): self._signature = state['_signature'] @@ -2775,12 +2773,11 @@ class Signature: return hash((params, kwo_params, return_annotation)) def __eq__(self, other): - return (self is other or - (isinstance(other, Signature) and - self._hash_basis() == other._hash_basis())) - - def __ne__(self, other): - return not self.__eq__(other) + if self is other: + return True + if not isinstance(other, Signature): + return NotImplemented + return self._hash_basis() == other._hash_basis() def _bind(self, args, kwargs, *, partial=False): """Private method. Don't use directly.""" |