Skip to content

Conversation

@lev-blit
Copy link
Contributor

source repo: https://github.com/miguelgrinberg/simple-websocket

in his other repositories (python-socketio, python-engineio and more) the maintainer stated that they aren't interested in adding in-line types to the repo, hence the addition to typeshed

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@lev-blit lev-blit marked this pull request as ready for review November 1, 2025 13:50
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, a few remarks.

async def connect(self) -> None: ...
async def handshake(self) -> None: ...
async def send(self, data: bytes | Any) -> None: ...
async def receive(self, timeout: float | None = None) -> bytes | str | Any: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

We now require a comment whenever Any is used in a non-obvious way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was an error on my part, thanks - it was meant to be None :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

send() also has Any.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll go over all the places that have any 👍🏼


class AioServer(AioBase):
request: _AioServerRequest
headers: dict[str, Any]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we don't require it, because dict[str, Any] is a very common idiom and obvious.

@type_check_only
class _ThreadClassProtocol(Protocol):
name: str
def __init__(self, target: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we use a ParamSpec here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on second read - it doesn't actually need args or kwargs - the code only uses target


@type_check_only
class _SelectorClassProtocol(Protocol):
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above: We need a comment for how data is used and why it's Any.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 1, 2025

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit 62dc403 into python:main Nov 1, 2025
48 checks passed
@lev-blit lev-blit deleted the feature/simple-websocket branch November 1, 2025 15:34
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