From 5880769cbac1362aad46a34faec4c553fa9fcac6 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Thu, 20 Nov 2025 09:58:28 -0500 Subject: Add get and __contains__ methods to all *MetaClass Fixes: https://github.com/Vector35/binaryninja-api/issues/7588 --- python/update.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'python/update.py') diff --git a/python/update.py b/python/update.py index 308094f7..f88770fd 100644 --- a/python/update.py +++ b/python/update.py @@ -20,6 +20,7 @@ import traceback import ctypes +from typing import Any, Optional # Binary Ninja components import binaryninja @@ -65,6 +66,23 @@ class _UpdateChannelMetaClass(type): raise KeyError("'%s' is not a valid channel" % str(name)) return result + def __contains__(cls: '_UpdateChannelMetaClass', name: object) -> bool: + if not isinstance(name, str): + return False + try: + cls[name] + return True + except KeyError: + return False + + def get(cls: '_UpdateChannelMetaClass', name: str, default: Any = None) -> Optional['UpdateChannel']: + try: + return cls[name] + except KeyError: + if default is not None: + return default + return None + class UpdateProgressCallback: def __init__(self, func): -- cgit v1.3.1