device: Fix crash in NotificationFlag.flag_names when flags is None (#3185)

flag_names() crashes with AttributeError when NotificationFlag returns
a value whose .name attribute is None. This occurs with certain receiver
firmware versions (Nano C52F, Unifying C52B, Bolt C548).

Return an empty list instead, consistent with the List[str] return type.

Fixes #3184

Co-authored-by: avercelli <avercelli@vulog.com>
This commit is contained in:
Alessio85 2026-04-13 18:46:43 +02:00 committed by GitHub
parent 5478224cfa
commit 7d571d855f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -91,6 +91,8 @@ class NotificationFlag(IntFlag):
@classmethod
def flag_names(cls, flags) -> List[str]:
"""Extract the names of the flags from the integer."""
if flags is None or flags.name is None:
return []
return flags.name.replace("_", " ").lower().split("|")
NUMPAD_NUMERICAL_KEYS = 0x800000