-
Notifications
You must be signed in to change notification settings - Fork 426
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
Clean up battery, alert and hidpp related code #2428
Conversation
3b2cb39
to
4719827
Compare
Don't know what's the issue with the more or less unrelated test failure |
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.
The first two commits look fine.
The third commit looks fine. |
I do not understand the rationale for creating fake classes for a small part of Device. |
Which fake classes? |
Can IntEnum be used instead of NamedInt everywhere in Solaar? If so, then it is a good idea to do the replacement. If not, then Solaar should stick with NamedInt throughout. The NamedInts that need to be checked are the ones that have default values, I think. |
DeviceProtocol |
The protocol makes clear which functions are used in that module. And that's the foundation for further decoupling to simplify the code complexity and enable boring, but effective tests and implementations. |
33e1847
to
9df4aab
Compare
@pfps ready |
9df4aab
to
36e5bb4
Compare
dc3587d
to
e5484d3
Compare
I am not convinced of the need to add the protocols. If there is a PR without these commits, I'll merge it in. |
The protocols are important for further clean up of the data read/write related code, as they indicate, which actions are needed in a module. The hidpp, device and base modules have interesting data paths and thus dependencies, which can be tackled on top of that. |
If the prototols are important for future work split them off for now. When the future work is being performed they can be re-evaluated. |
cd08733
to
6ec8122
Compare
Fixed and simplified |
I'm seeing extra messages when running
|
@MattHag Is there a better way to set up the Linux vs MacOS hid code? Would it be a good idea to move the hidapi directory to be a subdirectory of logitech_receiver? |
Yes, there's certainly a different one, but it's not the most relevant. No, all those low level communication interface should be self-contained and have no dependency or tight connection to the main Solaar code |
The problem is that currently Solaar installs hidapi as a top-level module in .../site-packages and there is a separate hidapi package in PyPI. So either Solaar should just use that package or the Solaar HID code should be moved inside the low-level part of Solaar, i.e., inside logitech_receiver. The question is which way to go and if the HID code is retained how best to interact with the two back-ends. At the same time, it is probably a good idea to rename logitech_receiver as it isn't just about receivers. |
3362457
to
e73c1ab
Compare
Kept the fileopen alias, now it will work again. |
e73c1ab
to
cbc45c5
Compare
Replace NamedTuples with more flexible dataclass, which also support type hints. Introduce enums to replace constant strings, which need to be kept in sync. Also enhances interfaces by limiting it to the enum values. Remove unused variables.
Replace unnecessary NamedInts in favour of default data types. Simplify interfaces by reducing possible input from strings to members of an enum.
8bc5af0
to
b157412
Compare
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.
Looks acceptable
It's imported unconditionally in: lib/solaar/ui/about/presenter.py:19 lib/logitech_receiver/hidpp10.py:22 lib/logitech_receiver/hidpp20.py:35 Fixes 469c04f (committed as part of pwr-Solaar#2428).
Simplifies hierarchy, adds type hints and enhances readability. Fixes capitalization of constants, which is violated by NamedInts.
Related #2273