-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[simple-websocket]: add stubs for simple-websocket #14868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
srittau
left a comment
There was a problem hiding this 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: ... |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send() also has Any.
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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: ... |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: ... |
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
source repo: https://github.com/miguelgrinberg/simple-websocket
in his other repositories (
python-socketio,python-engineioand more) the maintainer stated that they aren't interested in adding in-line types to the repo, hence the addition to typeshed