-
Notifications
You must be signed in to change notification settings - Fork 10
add type annotations #18 #23
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.
Thanks for working on this @matt-land I noted a few potential changes in some different sections of the code, but this is looking pretty good to me overall.
def _write_pixels( | ||
output_file: BufferedWriter, | ||
pixel_source: Union[Bitmap, Display], | ||
palette: Optional[Palette], |
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.
Is palette really optional here? it doesn't default to None
and it looks like there is an attempt to access a value from it using square brackets inside of this function without any further check for None that I'm seeing.
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 think Palette is optional. The function takes either a (bitmap & palette) and follows the first major branch or (Display & None) and follows the second major branch of the function.
Related: I added and "# handled by save_pixel's guardians" after I figured this out
Should I make palette default to None? or remove the Optional type decorator?
ab4244d
to
d61c5ed
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 good to me. Thanks again @matt-land
We'll keep the mypy ini file for now and adjust as needed when something is rolled out across all of the libraries.
Updating https://github.com/adafruit/Adafruit_CircuitPython_BH1750 to 1.1.0 from 1.0.7: > Merge pull request adafruit/Adafruit_CircuitPython_BH1750#6 from DeadSix27/main > Patch .pre-commit-config.yaml > 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_CircuitPlayground to 5.2.1 from 5.2.0: > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#117 from Neradoc/frozen-module-subdirectory Updating https://github.com/adafruit/Adafruit_CircuitPython_DS1307 to 2.1.10 from 2.1.9: > Merge pull request adafruit/Adafruit_CircuitPython_DS1307#24 from coplate/main > Patch .pre-commit-config.yaml > 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_UC8151D to 1.1.0 from 1.0.2: > Merge pull request adafruit/Adafruit_CircuitPython_UC8151D#4 from HDR/main > Patch .pre-commit-config.yaml > change discord badge > Patch: Replaced discord badge image > Updated gitignore > Update Black to latest. > Fixed readthedocs build > Post-patch cleanup > Consolidate Documentation sections of README Updating https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver to 1.2.1 from 1.2.0: > Merge pull request adafruit/Adafruit_CircuitPython_BitmapSaver#23 from matt-land/add-typing > Patch .pre-commit-config.yaml
Adding type hints for functions. This does not currently pass all mypy. The 4 remaining issues are as follows (and beyond my expertise):