mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
inspect: Add some comments in Parameter.__eq__ method
This commit is contained in:
parent
5334bcdf97
commit
0ba5f0d386
1 changed files with 11 additions and 0 deletions
|
@ -1905,6 +1905,17 @@ class Parameter:
|
||||||
id(self), self.name)
|
id(self), self.name)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
# NB: We deliberately do not compare '_partial_kwarg' attributes
|
||||||
|
# here. Imagine we have a following situation:
|
||||||
|
#
|
||||||
|
# def foo(a, b=1): pass
|
||||||
|
# def bar(a, b): pass
|
||||||
|
# bar2 = functools.partial(bar, b=1)
|
||||||
|
#
|
||||||
|
# For the above scenario, signatures for `foo` and `bar2` should
|
||||||
|
# be equal. '_partial_kwarg' attribute is an internal flag, to
|
||||||
|
# distinguish between keyword parameters with defaults and
|
||||||
|
# keyword parameters which got their defaults from functools.partial
|
||||||
return (issubclass(other.__class__, Parameter) and
|
return (issubclass(other.__class__, Parameter) and
|
||||||
self._name == other._name and
|
self._name == other._name and
|
||||||
self._kind == other._kind and
|
self._kind == other._kind and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue