-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
This comment has been minimized.
This comment has been minimized.
@@ -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, |
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.
Missing Unpack?
|
||
class _EngineIOServerConfig(TypedDict, total=False): | ||
async_mode: Literal["threading", "eventlet", "gevent", "gevent_uwsgi"] | ||
ping_interval: int # seconds |
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 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.
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.
Yeah, I think it can be float based on the test cases.
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. 🤖🎉 |
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