Comments (9)
@miguelgrinberg As I commented in the PR, I have already removed the private classes and attributes.
from flask-socketio.
Feel free to contribute type hints for this package to typeshed. I don't discard that at some point in the future when Python typing is mature enough I will do this myself, but I have too many open source packages and I cannot take on the burden of maintaining type hints for all of them given the effort it currently entails.
from flask-socketio.
@miguelgrinberg I created this pull request in typeshed
repository to add type stubs for Flask-SocketIO
. Could you please have a look at it and let me know if I have written the wrong type anywhere?
from flask-socketio.
I did a very quick review and wrote down some comments. In addition, I personally do not agree with adding types for private classes, attributes and methods, since people shouldn't use them and they are also much more likely to change since I have no obligation to preserve them. But of course, it is your project, so do as you wish. :)
from flask-socketio.
I personally do not agree with adding types for private classes, attributes and methods
I don't think I type hinted any private attributes or methods (please correct me if I did). I did type hint private classes, since the classes were the type of some public arguments. I'm not sure how else to type hint these public arguments.
For example, I type hinted _SocketIOMiddleware
because it's the type of this public attribute: sockio_mw: _SocketIOMiddleware | None
from flask-socketio.
sockio_mw
is not a documented attribute. In fact, none of the attributes of class SocketIO
are documented, only the methods are. I don't have an obligation to maintain compatibility for undocumented elements, and for that reason nobody should use them unless they are willing to assume a risk. My opinion is that those should not be exposed in type hints. Check my documentation, anything that is not there should be considered private.
from flask-socketio.
Another thing to consider is that you are using the |
character liberally in your type hints. If I remember correctly this syntax is only valid for Python 3.10+, but this package supports older Python releases. So maybe it makes more sense to use the more verbose Union
and Optional
type hints.
from flask-socketio.
Another thing to consider is that you are using the
|
character liberally in your type hints. If I remember correctly this syntax is only valid for Python 3.10+, but this package supports older Python releases. So maybe it makes more sense to use the more verboseUnion
andOptional
type hints.
@miguelgrinberg Actually the type stubs won't be read by the Python interpreter directly, but rather by static analyzers like mypy
, so it's safe to use the latest syntax.
from flask-socketio.
You don't seem to understand what I'm saying. If you add types for private elements of the library, users will be more likely to incorporate them in their programs. And these programs will later break when I need to change those internals, which I often do.
from flask-socketio.
Related Issues (20)
- Cannot start multiple threads HOT 1
- Support for once to listen for an event only 1 time (Like official socket.io server has) HOT 1
- Error when using gevent with allow_unsafe_werkzeug HOT 2
- Option to redirect http to https instead of raising errors HOT 1
- Strange Behavior with RabbitMQ and Flask-SocketIO HOT 4
- get_received(namespace=None) does not returns the messages HOT 5
- Socket.IO test client does not run background task HOT 7
- gevent - cannot enter into function. HOT 1
- Multiple SocketIO instances connected to the same Flask server HOT 1
- python-engineio and python-socketio version matching with Flask-SocketIO >= 5.3.0 HOT 1
- Flask-SocketIO cannot run in ws HOT 1
- pyinstaller Packaging error HOT 1
- How do I intercept event events and authenticate them in a unified manner?
- Waiting for client events leads to timeouts
- Sending events in a separate thread with delays does not send HOT 1
- Sending high volume of packets in short amount of time causes packets dropping HOT 5
- Namespace catch-all handling? HOT 9
- Namespace catch-all handling of connect/disconnect events HOT 1
- Flask-SocketIO returns [] on `get_received` function call HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-socketio.