-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Added context manager for Device ('with'-support) #108
base: master
Are you sure you want to change the base?
Conversation
…, clarified some error messages, took some steps towards Black formatting
Usage is now:
I would prefer:
Much like opening a file. |
Can you please add backwards compatibility for the rename, so also the old |
@prusnak I've added exactly that. |
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.
Hi,
I'm sorry for the unsolicited review, but as the maintainer of project that depends on cython-hidapi, I reviewed this and also tested it for backwards compatibility.
I left a few comments, please take a look at them when possible.
Reverted all (potentially) breaking changes. |
I added
__enter__
and__exit__
methods to enable context manager support. This makes uses of a device more pythonic.I also renamed
device
toDevice
, since it's a class. I added an alias with a warning fordevice
, so existing code would keep running.Having said this out loud, the class renaming should have been a separate PR. Let me know and I'll split it again.