summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2014-01-31 20:30:30 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2014-01-31 20:30:30 (GMT)
commit0ba5f0d3866a2bfa42cba3d809fc1c5d90faaf10 (patch)
treeef33ca3ee668516a78cc408e991218709e1c5935 /Lib/inspect.py
parent5334bcdf97e3a926fd9c30e520ed31ccb01038db (diff)
downloadcpython-0ba5f0d3866a2bfa42cba3d809fc1c5d90faaf10.zip
cpython-0ba5f0d3866a2bfa42cba3d809fc1c5d90faaf10.tar.gz
cpython-0ba5f0d3866a2bfa42cba3d809fc1c5d90faaf10.tar.bz2
inspect: Add some comments in Parameter.__eq__ method
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 4842965..a65aafd 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1905,6 +1905,17 @@ class Parameter:
id(self), self.name)
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
self._name == other._name and
self._kind == other._kind and