Skip to content

Commit

Permalink
Add a comment describing what is different from before
Browse files Browse the repository at this point in the history
  • Loading branch information
wesselb committed May 24, 2024
1 parent 03c4276 commit b07646d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions plum/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,26 @@ def __le__(self, other) -> bool:
other_varargs = beartype.door.TypeHint(other.varargs)
return self_varargs <= other_varargs

elif self.has_varargs:
# In this case, we have that `other >= self` is `False`, so returning
# `True` gives that `other < self` and returning `False` gives that
# `other` cannot be compared to `self`. Regardless of the return
# value, `other != self`.
#
# Previously, this returned `False`, which would implement the subset
# relationship. We now deviate from the subset relationship! The
# rationale rationale for this is as follows.
#
# A non-variable-arguments signature is compared to a variable-arguments
# signature only to determine which is more specific. At this point, the
# non-variable-arguments signature has number of types equal to the
# number of arguments given to the function, so any additional variable
# arguments are not necessary. Hence, we ignore the additional
# variable arguments in the comparison and return `True`.
return True
elif other.has_varargs:
return True

else:
return True

Expand Down

0 comments on commit b07646d

Please sign in to comment.