Skip to content
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

Flask-socketio 5.5 + add type of kwargs #13271

Merged
merged 6 commits into from
Dec 23, 2024

Conversation

yangdanny97
Copy link
Contributor

closes #13268

The new member is a type alias for something in python-socketio (untyped) by the same author, so I don't think I can add an annotation for it.

That class's constructor has a TODO for typing the kwargs, so I added types for those. There's two groups of configs so I defined two separate typed dicts.

SocketIO options
https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/src/flask_socketio/__init__.py#L82

EngineIO options
https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/src/flask_socketio/__init__.py#L114

This comment has been minimized.

@yangdanny97 yangdanny97 marked this pull request as ready for review December 20, 2024 15:32
@@ -35,7 +61,7 @@ class SocketIO:
channel: str = "flask-socketio",
path: str = "socket.io",
resource: str = "socket.io",
**kwargs, # TODO: Socket.IO server options, Engine.IO server config
**kwargs: _SocketIOKwargs,
Copy link
Member

Choose a reason for hiding this comment

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

Missing Unpack?


class _EngineIOServerConfig(TypedDict, total=False):
async_mode: Literal["threading", "eventlet", "gevent", "gevent_uwsgi"]
ping_interval: int # seconds
Copy link
Member

Choose a reason for hiding this comment

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

This can also be a two-tuple "For advanced control, a two element tuple can be given, where the first number is the ping interval and the second is a grace period added by the server."

I also suspect it can be a float instead of an int but haven't verified.

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 comment has been minimized.

Copy link
Contributor

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

@JelleZijlstra JelleZijlstra merged commit bfb9a91 into python:main Dec 23, 2024
48 checks passed
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