Expected type ‘socket.pyi‘, got ‘Tuple[Any, Any]‘ instead

使用paramiko连接远程linux服务器的时候,代码这个地方报错:
在这里插入图片描述
查了很多资料都没有把这个下划线去掉,回到paramiko.Transport()的使用方法:

    def __init__(
        self,
        sock,
        default_window_size=DEFAULT_WINDOW_SIZE,
        default_max_packet_size=DEFAULT_MAX_PACKET_SIZE,
        gss_kex=False,
        gss_deleg_creds=True,
        disabled_algorithms=None,
    ):
        """
        Create a new SSH session over an existing socket, or socket-like
        object.  This only creates the `.Transport` object; it doesn't begin
        the SSH session yet.  Use `connect` or `start_client` to begin a client
        session, or `start_server` to begin a server session.

        If the object is not actually a socket, it must have the following
        methods:

        :param socket sock:
            a socket or socket-like object to create the session over.

参数sock:
一个套接字或类似套接字的对象来创建会话

套接字:IP地址+端口号

虽然我还是没有搞清楚下划线警告什么,但是我感觉没有错,就直接运行了,果然可以通过!
所以下次大家遇到问题不要过于拘谨,直接运行试试,不行了再调bug~~~
完整的paramiko使用参考链接

猜你喜欢

转载自blog.csdn.net/liulanba/article/details/115162382