Skip to content

fix type of loop.sock_connect#3073

Merged
srittau merged 3 commits intopython:masterfrom
JelleZijlstra:sockconnect
Jun 21, 2019
Merged

fix type of loop.sock_connect#3073
srittau merged 3 commits intopython:masterfrom
JelleZijlstra:sockconnect

Conversation

@JelleZijlstra
Copy link
Member

I ran into a place in our code where we pass a (host, port) tuple to sock_connect. According to https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.sock_connect, the address argument is the same as that to socket.connect (https://docs.python.org/3/library/socket.html#socket.socket.connect), so I use the same type alias used for socket.

socket.connect also takes bytes according to our annotations, but from my experiments it seems that asyncio's version does not.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, one optional comment, fine to merge either way.

def sock_sendall(self, sock: socket, data: bytes) -> Generator[Any, None, None]: ...
@coroutine
def sock_connect(self, sock: socket, address: str) -> Generator[Any, None, None]: ...
def sock_connect(self, sock: socket, address: _Address) -> Generator[Any, None, None]: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is inherited from AbstractEventLoop and not even overridden in BaseEventLoop, so it can be removed here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, my bad. While it seems that BaseEventLoop is indeed abstract, it is not marked as such. Probably easiest to re-add sock_connect().

@srittau srittau merged commit b0c9fa4 into python:master Jun 21, 2019
@JelleZijlstra JelleZijlstra deleted the sockconnect branch May 30, 2020 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants