-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
make CloseReason an Enum? #59
Comments
I'd like this as well. There's already an enum in wsproto that could be reused: https://github.com/python-hyper/wsproto/blob/master/wsproto/frame_protocol.py#L85 Caveat: there are valid close codes that do not have names, so there still needs to be a way to instantiate instances with just a code number and optional reason string. |
It sounds like a good reason for trio-websocket to maintain its own enum. (Plus wsproto enum doesn't have reason string.) Is anything of wsproto exposed currently? |
Nothing in wsproto is part of the public trio-websocket API—except for the imported modules that are set to be hidden when the library is re-organized. |
I looked at this again:
Proposed:
I'm not a big fan of IntEnum due to str() gotchas, but it seems suitable in this case since we want users to easily compare the int We could also consider having |
i.e. enum with code as value, and a reason attribute
I'd like to be able to compare close reason without resorting to string comparison
The text was updated successfully, but these errors were encountered: