From 1074c410331d50c952200fbef0c7851b8deaeea4 Mon Sep 17 00:00:00 2001 From: Jophy Chon Hou Ye Date: Sat, 10 Aug 2024 12:41:54 +0800 Subject: [PATCH 1/4] Added function prototype for BaseChannelLayer --- channels/layers.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/channels/layers.py b/channels/layers.py index 48f7baca..fd373167 100644 --- a/channels/layers.py +++ b/channels/layers.py @@ -186,6 +186,31 @@ def non_local_name(self, name): else: return name + async def send(self, channel, message): + raise NotImplementedError("send() should be implemented in channels") + + async def receive(self, channel): + raise NotImplementedError("receive() should be implemented in channels") + + async def new_channel(self): + raise NotImplementedError("new_channel() should be implemented in channels") + + # flush extension + + async def flush(self): + raise NotImplementedError("flush() called but not implemented (flush extension)") + + # groups extension + + async def group_add(self, group, channel): + raise NotImplementedError("group_add() not implemented (groups extension)") + + async def group_discard(self, group, channel): + raise NotImplementedError("group_discard() not implemented (groups extension)") + + async def group_send(self, group, message): + raise NotImplementedError("group_send() not implemented (groups extension)") + class InMemoryChannelLayer(BaseChannelLayer): """ From 40d0755709758cbfdb8af8659bcf87a4ceec6c7d Mon Sep 17 00:00:00 2001 From: Jophy Ye <44258870+jophy-ye@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:26:20 +0800 Subject: [PATCH 2/4] Refactor layers.py according to linter --- channels/layers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/channels/layers.py b/channels/layers.py index fd373167..50d215f6 100644 --- a/channels/layers.py +++ b/channels/layers.py @@ -191,15 +191,15 @@ async def send(self, channel, message): async def receive(self, channel): raise NotImplementedError("receive() should be implemented in channels") - + async def new_channel(self): raise NotImplementedError("new_channel() should be implemented in channels") - + # flush extension async def flush(self): raise NotImplementedError("flush() called but not implemented (flush extension)") - + # groups extension async def group_add(self, group, channel): From 09aaf6dbded50db4c3277f4ba4ea3b6c817ca4cf Mon Sep 17 00:00:00 2001 From: Jophy Ye <44258870+jophy-ye@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:31:35 +0800 Subject: [PATCH 3/4] Refactor layers.py according to linter --- channels/layers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channels/layers.py b/channels/layers.py index 50d215f6..480de199 100644 --- a/channels/layers.py +++ b/channels/layers.py @@ -198,7 +198,7 @@ async def new_channel(self): # flush extension async def flush(self): - raise NotImplementedError("flush() called but not implemented (flush extension)") + raise NotImplementedError("flush() not implemented (flush extension)") # groups extension From 35072e11ff386d24c3604deb078da9115765770d Mon Sep 17 00:00:00 2001 From: Jophy Ye <44258870+jophy-ye@users.noreply.github.com> Date: Sat, 10 Aug 2024 18:29:24 +0800 Subject: [PATCH 4/4] Update function prototype error message --- channels/layers.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/channels/layers.py b/channels/layers.py index 480de199..99e7fbd6 100644 --- a/channels/layers.py +++ b/channels/layers.py @@ -187,21 +187,19 @@ def non_local_name(self, name): return name async def send(self, channel, message): - raise NotImplementedError("send() should be implemented in channels") + raise NotImplementedError("send() should be implemented in a channel layer") async def receive(self, channel): - raise NotImplementedError("receive() should be implemented in channels") + raise NotImplementedError("receive() should be implemented in a channel layer") async def new_channel(self): - raise NotImplementedError("new_channel() should be implemented in channels") - - # flush extension + raise NotImplementedError( + "new_channel() should be implemented in a channel layer" + ) async def flush(self): raise NotImplementedError("flush() not implemented (flush extension)") - # groups extension - async def group_add(self, group, channel): raise NotImplementedError("group_add() not implemented (groups extension)")