-
Notifications
You must be signed in to change notification settings - Fork 490
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
[debug] improve debug readability #470
Conversation
I've been working on better debug output on the side and didn't have the opportunity to commit anything yet. |
@xs5871 Nice! glad to here that. This MR does not change many things so I guess it will not interfer much with that work. It might still be nice to have it until you have that new debug ready ? |
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.
Approving the idea; I have a remark inline that OP and @xs5871 can work out whether they want to take or leave but aside from that this LGTM.
kmk/kmk_keyboard.py
Outdated
txt += f' unicode_mode={self.unicode_mode}, _hid_helper={self._hid_helper},\n' | ||
txt += f' keys_pressed={self.keys_pressed}\n' | ||
txt += f' _coordkeys_pressed={self._coordkeys_pressed}\n' | ||
txt += ' hid_pending={}, active_layers={}, _timeouts={}\n)'.format( |
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.
Why is this not an f-string but the others are?
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.
those are not fstring as that would make the line too long. The goal of fstring is to give an option that in most case is a more readable string. Here the more readable, given the lenght, is the format. as it is each argument is below it's corresponding {}.
It was also an attempt to have both not too long line, and "the output will look exactly like the string is formated in the code" you suggested.
I can split it into more fstring line if the consistency of string formatting is wanted. (I can even push a commit to remove all .format()
given the low number of them if you want).
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.
I'll leave the final call to @xs5871 but I believe that consistency makes more sense personally, but I suppose that's a valid point.
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.
+1 to consistency.
When I suggested "make it an f-string" I had a single multi-line f-string in mind. The x += '*\n'
feels quite unpythonic.
I have to say, this discussion has been going on for almost to long, considering this concerns such a minor change.
It's probably because we started with a complex, possibly over-engineered (no offense, we all do over-engineer sometimes; also it's fun), solution and step for step reverted it back to a pragmatic one, instead of starting from scratch.
At this point, we could just as well keep the original code, just with a couple of newlines thrown into it.
281a785
to
c3b0b6d
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.
I know these aren't the changes you originally wanted in there, but I believe this is easy to read, and improves debug-ability quite a bit.
|
Sorry I did not fully tested the fstring change before upload but got back to my board:
|
Looks good, verified on hardware. Thanks for sticking with the issue. |
Ah, yeah, when I wrote CircuitPython's f-strings implementation I left some comments about that concatenation error. Technically this means Micro+CircuitPython are not actually PEP-498 compliant, but both upstreams agreed with me that the tradeoff was worthwhile. Definitely confusing the first time one runs into it, though :\ https://github.com/adafruit/circuitpython/pull/2690/files#diff-e4737fa9a48c19ab35f9083a424c50059a6e94008f7d2aeaa4418eab7b3bc332R86-R102 |
little tweak in the debug output to make things more readable:
example result: