Make Plover HID not fail on startup#1808
Conversation
268a100 to
1f7ce9f
Compare
|
Thank you @user202729! The current way of installing I noticed, however, that hidapi 0.15.0 was recently released on PyPI. I did some tests and this version does fix the issue with macOS ( If it's fine for you, let's park your PR in case I'm not successful with moving to that |
|
#1812 fixes the issue on the machine I tested. Caveat is that the user must make sure that That said, I don't understand how the linked pull request is supposed to fix the issue raised in this pull request. Quoting documentation of
if the last entry is not installed, we would still get some sort of error? I notice the dependency installs a |
|
Thanks @user202729 for testing with #1812. I assume you only checked if Plover works but not the Plover HID functionality itself? I'm asking because I'm having trouble getting the Plover HID keyboard to work on Linux. Windows and maCOS work perfectly. |
|
Indeed, I don't need the functionality (currently I use the Keyboard machine with some local modifications to only activate on one keyboard but not another. I may upstream this feature eventually, but it's somewhat nontrivial…), only check that the error doesn't show up. |
Summary of changes
From the documentation of
hid(typo not mine):This may not be installed, which means the import may raise
ImportError.For me, if that library is not installed,
import hidfails withat startup. This change makes it so that it only fail when the user tries to select
Plover HIDas the input source.Note: we don't actually need to depend on
hid, that can be left as an optional dependency.The
from __future__ import annotationsis just in case, because there are several type annotations that usehid.something, and on sufficiently-old Python versions they will actually be evaluated and raise errors (depends on what is the minimum-supported version this may not be necessary)Note: only tested on Linux.
Note: I consider the case where the first
import hidfails but the second succeed extremely unlikely, but it may look cleaner to capture the error message in the first import andlog.error()it when started.Pull Request Checklist