pythonpython-typingpython-sockets

What is the type hint for socket?


Suppose I'm writing a function that takes a socket as a parameter. How should I type hint it properly?

def read_socket(socket: ???):
    ....

Solution

  • The type is just socket.socket.

    import socket
    
    def f(sock: socket.socket): ...