Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ba5f0d

Browse files
committed
inspect: Add some comments in Parameter.__eq__ method
1 parent 5334bcd commit 0ba5f0d

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Lib/inspect.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,17 @@ def __repr__(self):
19051905
id(self), self.name)
19061906

19071907
def __eq__(self, other):
1908+
# NB: We deliberately do not compare '_partial_kwarg' attributes
1909+
# here. Imagine we have a following situation:
1910+
#
1911+
# def foo(a, b=1): pass
1912+
# def bar(a, b): pass
1913+
# bar2 = functools.partial(bar, b=1)
1914+
#
1915+
# For the above scenario, signatures for `foo` and `bar2` should
1916+
# be equal. '_partial_kwarg' attribute is an internal flag, to
1917+
# distinguish between keyword parameters with defaults and
1918+
# keyword parameters which got their defaults from functools.partial
19081919
return (issubclass(other.__class__, Parameter) and
19091920
self._name == other._name and
19101921
self._kind == other._kind and

0 commit comments

Comments
 (0)