From 2d88c00cd753260d2682833d427d2f9d074a02be Mon Sep 17 00:00:00 2001 From: jan Date: Thu, 12 Oct 2023 01:32:33 -0700 Subject: [PATCH] Add NoReturn __contains__ with a more descriptive error message --- masque/ports.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/masque/ports.py b/masque/ports.py index 6179f87..b1943a3 100644 --- a/masque/ports.py +++ b/masque/ports.py @@ -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