You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
Cannot access member "sio" for type "FastAPI"
Member "sio" is unknown
Which makes sense because as far as VSCode knows FastAPI doesn't have an attribute sio. Is there a way this can be fixed ? For example adding custom stub types ?
Thanks
The text was updated successfully, but these errors were encountered:
That's going to be kinda hard when SocketManager magically creates a .sio on the app that's passed as an argument.
One option would be to start with app = cast(FastAPIWithSocketIO, FastAPI()) or equivalent.
The downside of that approach is only one enrichment can be used at a time -- what happens the user wants to use another fastapi-foobario library that behaves this way?
Ideally I'd be able to declare app extensions like so: app.sio: SIO|None = None, but alas, "Type cannot be declared in assignment to non-self attribute", see e.g. python/mypy#2388
So... today, IMHO, the only solution is not to keep the sio object on the app.
After all, I think global app singleton access is a bit of an anti-pattern (consider a larger app with many routers).
So, I would propose to have a separate sio global instead of app.sio
Ultimately, while socket_manager and app.sio are different objects, the documentation claims that they can be used [mostly] interchangeably to e.g. .emit(...) messages:
Hi,
Within VSCode I'm getting some type errors:
Which makes sense because as far as VSCode knows FastAPI doesn't have an attribute
sio
. Is there a way this can be fixed ? For example adding custom stub types ?Thanks
The text was updated successfully, but these errors were encountered: