From 2102082478e04ce3e1de96c6fafcc8a935fb4693 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Fri, 29 Jan 2021 21:41:38 +1100 Subject: [PATCH] Make Tok2Vec.remove_listener return bool Whether listener was removed --- spacy/pipeline/tok2vec.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/pipeline/tok2vec.py b/spacy/pipeline/tok2vec.py index eb6679834..fecf7029b 100644 --- a/spacy/pipeline/tok2vec.py +++ b/spacy/pipeline/tok2vec.py @@ -82,7 +82,7 @@ class Tok2Vec(TrainablePipe): self.listener_map.setdefault(component_name, []) self.listener_map[component_name].append(listener) - def remove_listener(self, listener: "Tok2VecListener", component_name: str) -> None: + def remove_listener(self, listener: "Tok2VecListener", component_name: str) -> bool: """Remove a listener for a downstream component. Usually internals.""" if component_name in self.listener_map: if listener in self.listener_map[component_name]: @@ -90,6 +90,8 @@ class Tok2Vec(TrainablePipe): # If no listeners are left, remove entry if not self.listener_map[component_name]: del self.listener_map[component_name] + return True + return False def find_listeners(self, component) -> None: """Walk over a model of a processing component, looking for layers that