-
Notifications
You must be signed in to change notification settings - Fork 489
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
Static Type Checking #226
Static Type Checking #226
Conversation
Updates Pipfile.lock Updates pyproject.toml with some initial pyright configuration
Update pyproject.toml
Bring in typings folder for adafruit_ble and micropython
Update pyproject.toml to ignore boards, user_keymaps for mypy Update pyproject.toml to reduce loud mypy reporting
Update refs from KeyAttrDict to Key in encoder.py Update types.py for validity Complete typing of key_validators.py
@sofubi: Damn This is awesome and I wish I had more words to appreciate this work with, but sometimes a single swear is more than enough, so let's dive in.
I'll admit that I did a quick skim and not a deep dive - I think these are my main two remarks for now, but I can't guarantee I won't have more thoughts in the future. At the very least, this is a huge start, so thank you for that! |
I'm dumb, on point 1 I see you talked about the |
@klardotsh going to respond first to the question of adding to the Makefile then to the
Once you have a chance to really dig in let me know if you see any other real offenders that I can clean up. I was pretty careful to jump through the codebase when typing things though so I'm guessing there shouldn't be too many problems (hopefully 🙏 ). |
I guess the only critical question (that could change the implementation in any significant way) I have right now is: has this code been run on a board with the type hints in the actual source? I was under the impression the PEPs for that syntax haven't been implemented in CircuitPython yet, and that we were gonna need to use the comment-based syntax. Was my assumption incorrect/outdated? |
I need to test this on a board. I have some pm rp2040s that I can test on
and some Picos but I haven't had a chance. I did see that MicroPython
implements the Typing library but I'm not 100% on if CircuitPython does.
Just started a new job so I've been slow on progress here.
…On Sun, Aug 22, 2021 at 3:12 PM Josh Klar ***@***.***> wrote:
I guess the only critical question (that could change the implementation
in any significant way) I have right now is: has this code been run on a
board with the type hints in the actual source? I was under the impression
the PEPs for that syntax haven't been implemented in CircuitPython yet, and
that we were gonna need to use the comment-based syntax. Was my assumption
incorrect/outdated?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFZIIXHTY6EOF7XXEIUVETT6FDZZANCNFSM5CG6F4DQ>
.
|
Absolutely no rush - everything in KMK is at whatever pace the author can healthily handle, no need to burn anyone out. Good luck with the onboarding! |
I was able to test my branch on a Pro Micro 2040 and can confirm that the PEP for the syntax I have been using has not yet been implemented. I'm going to move to using the comment style syntax and attempt to brush up what's there now as well as move out the uses of |
Update Pipfile to add typing module and pyright Update pyproject.toml for pyright and mypy configs
Type Checking
As suggested by @kdb424 I'm going to open a draft PR for this so I can get eyes on ahead of making the PR.
Where I'm at so far:
Basically I'm through the modules folder, I've typed out everything I can reasonably in there and moved on up into
kmk_firmware.py
and the files around it.Issues I've faced:
I couldn't find type stubs for the
adafruit_ble
library so I created the ones I needed to get throughmodules/split.py
.I've added a single stub for
micropython
'sconst()
function which may need a quick validity check.Anything I absolutely cannot type (
boards.PIN_**
for instance) I've typed asAny
. In the instance ofboard.PIN_**
I've had to useAny
because it's not possible as far as I can tell to actually type those.What I could use:
Any feedback would be great! I would like to move back through this before submitting and maybe extract some of the really nasty type references out into separate aliases which I've done in a few instances.
Let me know if I'm on the right track with tooling, I've tried to make sure that the
pyproject.toml
is correctly set up but I do want to verify.Thanks!
This is fun and thanks for being so available. Really appreciate it. 🙏