From 59cf48e40e1bafdb27bea54695e5bc5c6dd81f81 2021-11-23 21:38:12 From: Nikita Kniazev Date: 2021-11-23 21:38:12 Subject: [PATCH] TST: Simplify `NamedInstanceClass` The `__getitem__`/`get_instance` methods are unused. --- diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py index c470b1f..4feba09 100644 --- a/IPython/core/tests/test_completer.py +++ b/IPython/core/tests/test_completer.py @@ -191,25 +191,16 @@ def test_line_split(): check_line_split(sp, [map(str, p) for p in t]) -class NamedInstanceMetaclass(type): - def __getitem__(cls, item): - return cls.get_instance(item) +class NamedInstanceClass: + instances = {} - -class NamedInstanceClass(metaclass=NamedInstanceMetaclass): def __init__(self, name): - if not hasattr(self.__class__, "instances"): - self.__class__.instances = {} - self.__class__.instances[name] = self + self.instances[name] = self @classmethod def _ipython_key_completions_(cls): return cls.instances.keys() - @classmethod - def get_instance(cls, name): - return cls.instances[name] - class KeyCompletable: def __init__(self, things=()):