From b07646db5f3a37435aa8ffd76ae27da8d120a92b Mon Sep 17 00:00:00 2001 From: Wessel Bruinsma Date: Fri, 24 May 2024 19:41:24 +0200 Subject: [PATCH] Add a comment describing what is different from before --- plum/signature.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plum/signature.py b/plum/signature.py index d71594a6..e62b322a 100644 --- a/plum/signature.py +++ b/plum/signature.py @@ -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