channels icon indicating copy to clipboard operation
channels copied to clipboard

feature: improve channel typings, add method stubs

Open devkral opened this issue 2 years ago • 5 comments

Currently the layers module is untyped and BaseChannelLayer is not a real interface (lacks stub methods)

This PR adds typings and stub methods (for type hinting and getting a meaningful error in case something is missing)

devkral avatar Jun 27 '23 11:06 devkral

ping?

devkral avatar Jan 28 '24 17:01 devkral

ping?

Yes, I'm not sure about this. It's a lot of noise for not much benefit as far as I can see.

Surely though, if we were adding types, a Protocol would be the way forward, rather than base class stub methods... 🤔

carltongibson avatar Jan 28 '24 17:01 carltongibson

The problem my PR solves is, that it is not obvious for programmers how to write a layer backend. Docstrings are spread around and you have to look in channels-redis too to make sense of the functions

Agreed a protocol would be maybe better later but it needs more refactory. I will implement this

devkral avatar Jan 29 '24 03:01 devkral

tried it. Protocol is not the right way I think, we should use abc classes, as the BaseChannelLayer implements also some real methods

devkral avatar Jan 29 '24 03:01 devkral

how do you think about this?

BaseChannelLayer is now abstract, the extensions are now runtime checkable Protocols.

If you think this is good, I can document the changes

devkral avatar Jan 29 '24 04:01 devkral