def class_by_prefix(
prefix: str,
-) -> Union[Type[GPS303Pkt], List[Tuple[str, int]]]:
+) -> Union[Type[GPS303Pkt], List[str]]:
+ if prefix.startswith(PROTO_PREFIX):
+ pname = prefix[len(PROTO_PREFIX) :]
+ else:
+ raise KeyError(pname)
lst = [
(name, proto)
for name, proto in PROTOS.items()
if name.upper().startswith(prefix.upper())
]
if len(lst) != 1:
- return lst
+ return [name for name, _ in lst]
_, proto = lst[0]
return CLASSES[proto]