-
Notifications
You must be signed in to change notification settings - Fork 50
Add type annotations #73
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
Conversation
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.
Awesome job with this, what a doozy! 😰
Feedback and comments attached, let me know if I can help explain anything!
Also, the bare asterisk signifies that any arguments following it, must be keyword-only, so it doesn't make sense to type annotate it since it's more of a sentinel character than actual argument. But I don't know how to argue with (or otherwise suppress) mypy! Maybe there is a suitable type annotation for it, but if so, we haven't been using it so no worries! |
I do hope this will get tested on hardware before merging. Normally I would be happy to do it, but I will not have access to my hardware for a free weeks. Good luck! |
Thanks so much for the feedback! I addressed everything as best I could. I saw another contributor say this earlier in a different PR, but this is legitimately the best first experience I have had with a project like this. I really appreciate the time and care taken to address this PR. There's certainly some tribal knowledge that is now much clearer than when I started, and I learned a few things :) I agree that testing on hardware would be good, I would be happy to jump forward and volunteer, but I started this at Pycon where there was hardware available, and unfortunately, I no longer have access to the hardware to test this. It is just type annotations though (aside from the requirements changes, and the new try/catch at the top) and should not (famous last words? I hope not :D ) affect the actual functionality of this library. However, I would probably feel better waiting on having this merged until it can be properly tested. |
@jcerise first of all, thank you for jumping in at PyCon to help with this. Don't let the comments of a curmudgeon like me dampen your enthusiasm ;-) |
Big agree - thank you for jumping in to help at PyCon, @jcerise! Glad it's been an enjoyable experience - it should! Type annotations are generally safe, but I would feel better building it if it's frozen in - I just never remember which libraries those are, so thank you @jerryneedell for mentioning that! I'll build it once it's ready to be safe. I can take care of testing that, @jcerise, but if you're wondering what we mean by "frozen in", here's some information: https://learn.adafruit.com/building-circuitpython/adding-frozen-modules Basically one build of the CircuitPython firmware has this cooked into it, so extra should be given to memory size (type annotations are ignored by the compiler I believe) and functionality (since this is cooked into firmware for specific boards, we get the benefit of the user not needed to provide this library, but it also means that any bugs will proliferate much more readily 😅) |
Echoing what a few have said, thanks so much for working on this @jcerise! My thoughts on a few things mentioned above: Regarding suppressing mypy, I think we don't need to worry about it for now. We don't have the checks put into our CI yet so for the time being it's okay if it's still complaining about some things. When the time comes to add it to our CI checks we'll discuss the way we want to configure it which I assume will suppress any messages that we can't or don't intend to comply with. regarding testing, we'll definitely test on hardware. I think I have some of the hardware to test this on. But it's also okay if we wait for a bit for jerry to return. I definitely believe that he's got more experience and hardware for testing more thoroughly than I. We can do the frozen build test as well to make sure we won't run into size trouble. I'm not actually sure what impact the types have on final size of the mpy file. I think they may get stripped somewhere in the process but I'm not sure if the net impact is really 0 or maybe something more. |
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.
Just a few minor changes that I think got missed. After those, we can try building the firmware :)
Thanks for the patience here. I realize I maybe should have chosen a smaller file for my first attempt, but with the guidance and discussion here, this has been great. My apologies for the silly mistakes above, those have been ironed out. |
Nah, no worries, thanks for the quick turnaround! |
Builds the Feather M0 RFM9x!
|
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.
Small question for @FoamyGuy
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 good to me.
I tested several of the examples included in the repo successfully with https://www.adafruit.com/product/3231 on PyGamer, EdgeBadge, and Feather RP2040 all on 7.3.0-beta.2
Thanks again for working on this @jcerise! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 5.4.1 from 5.4.0: > change discord badge > Patch: Replaced discord badge image > Updated gitignore > Update Black to latest. Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM9x to 2.2.4 from 2.2.3: > Merge pull request adafruit/Adafruit_CircuitPython_RFM9x#73 from jcerise/65/missing_type_annotations > change discord badge > Patch: Replaced discord badge image > Updated gitignore > Update Black to latest. > Fixed readthedocs build > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 1.16.1 from 1.16.0: > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#60 from matt-land/add-typing Updating https://github.com/adafruit/Adafruit_CircuitPython_JWT to 1.2.6 from 1.2.5: > Merge pull request adafruit/Adafruit_CircuitPython_JWT#11 from ktkinsey37/typing > change discord badge > Patch: Replaced discord badge image > Updated gitignore > Update Black to latest. > Fixed readthedocs build > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.7.2 from 0.7.1: > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#47 from jepler/example-updates-background > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#46 from jepler/neopixel-match-core > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#45 from jepler/background-morse
Addresses issue #65
Adds type annotations across the file.
Items of note: