Add NoReturn __contains__ with a more descriptive error message

This commit is contained in:
jan 2023-10-12 01:32:33 -07:00
parent c02c2f90ef
commit 3245de99b3

View File

@ -1,4 +1,4 @@
from typing import Iterable, KeysView, ValuesView, overload, Self, Mapping
from typing import Iterable, KeysView, ValuesView, overload, Self, Mapping, NoReturn
import warnings
import traceback
import logging
@ -138,6 +138,9 @@ class PortList(metaclass=ABCMeta):
else:
return {k: self.ports[k] for k in key}
def __contains__(self, key: str) -> NoReturn:
raise NotImplementedError('PortsList.__contains__ is left unimplemented. Use `key in container.ports` instead.')
# NOTE: Didn't add keys(), items(), values(), __contains__(), etc.
# because it's weird on stuff like Pattern that contains other lists
# and because you can just grab .ports and use that instead