This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/click in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 0156009ae218bdf38d6d749280ba2641aae3166e Author: Jürg Billeter <[email protected]> AuthorDate: Fri Sep 19 12:32:05 2025 +0200 types.py: Return `NotImplemented` for unsupported `FastEnum` operations As per https://docs.python.org/3/library/constants.html#NotImplemented: A special value which should be returned by the binary special methods (e.g. __eq__(), __lt__(), __add__(), __rsub__(), etc.) to indicate that the operation is not implemented with respect to the other type This fixes crashes with Click 8.3.0. --- src/buildstream/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/buildstream/types.py b/src/buildstream/types.py index efb338515..d4d5e3cdb 100644 --- a/src/buildstream/types.py +++ b/src/buildstream/types.py @@ -67,14 +67,14 @@ class FastEnum(metaclass=MetaFastEnum): def __eq__(self, other): if self.__class__ is not other.__class__: - raise ValueError("Unexpected comparison between {} and {}".format(self, repr(other))) + return NotImplemented # Enums instances are unique, so creating an instance with the same value as another will just # send back the other one, hence we can use an identity comparison, which is much faster than '==' return self is other def __ne__(self, other): if self.__class__ is not other.__class__: - raise ValueError("Unexpected comparison between {} and {}".format(self, repr(other))) + return NotImplemented return self is not other def __hash__(self):
