-
-
Notifications
You must be signed in to change notification settings - Fork 371
Closed
Labels
design discussiontypingAdding static types to trio's interfaceAdding static types to trio's interface
Description
SocketType is currently an empty type and what's meant for end-users to inherit from to show compatibility with trio sockets, but _SocketType (which inherits from SocketType is what's actually used internally and has all the methods needed to get code to actually pass type checking.
So we probably want to merge these one way or another, I started trying to tackle it in #2705 but all my ideas hit problems and will likely have some effect on user code that inherits from either of them, so I think it deserves it's own issue + PR.
In tests we have three different FakeSocket classes inheriting from SocketType: test_highlevel_socket.py, test_highlevel_open_tcp_stream.py and test_highlevel_open_tcp_listeners.py
Options include:
- Make
SocketTypean abstract base class with abstract methods. Will break any code that has methods inheriting from it and not defined - so would need to only mark the methods that are absolutely required to be abstract, and others could instead raiseNotImplementedError.
*. Will almost certainly raise a lot of type checking errors. - Remove _SocketType, moving it all into
SocketType. I think it's impossible to avoid this being a breaking API change. - Don't make any runtime changes at all, but during type checking assign
SocketType = _SocketType.
*. will raise a ton of type checking errors, might be possible to reduce the number with some effort. - Rename
_SocketTypesomething likeInternalTrioSocketTypeand have that be the class used in signatures that require some methods to be available. - ...
Metadata
Metadata
Assignees
Labels
design discussiontypingAdding static types to trio's interfaceAdding static types to trio's interface