-
Notifications
You must be signed in to change notification settings - Fork 70
doc(mypy): Add type annotations to function defintions #69
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
doc(mypy): Add type annotations to function defintions #69
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 @careyk007. I have suggestions on a few of them.
@FoamyGuy Thanks for the review! I added the additional types and some import statements to make the types available. |
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. Tested successfully example scripts on:
Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Feather RP2040 with rp2040
Board ID:adafruit_feather_rp2040
Updating https://github.com/adafruit/Adafruit_CircuitPython_ILI9341 to 1.3.1 from 1.3.0: > Merge pull request adafruit/Adafruit_CircuitPython_ILI9341#29 from FoamyGuy/type_info > Globally disabled consider-using-f-string pylint check Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel to 6.2.2 from 6.2.1: > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#119 from jsymons/typing > Globally disabled consider-using-f-string pylint check Updating https://github.com/adafruit/Adafruit_CircuitPython_Seesaw to 1.10.0 from 1.9.2: > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#85 from ladyada/master > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#81 from FoamyGuy/use_rainbowio > Globally disabled consider-using-f-string pylint check Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1306 to 2.12.2 from 2.12.1: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1306#69 from careyk007/add_missing_type_annotations > Globally disabled consider-using-f-string pylint check Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7789 to 1.5.2 from 1.5.1: > Merge pull request adafruit/Adafruit_CircuitPython_ST7789#27 from helgibbons/Display-Pack-2.0 > Globally disabled consider-using-f-string pylint check
I've taken a stab at #68.
I tried to figure out the correct types and avoid the use of
Any
as much as possible. I can try to dig deeper and remove some of the remainingAny
s if that would be helpful.I ran the command
mypy --disallow-untyped-defs --disallow-incomplete-defs --ignore-missing-imports adafruit_ssd1306.py
for verification and received the following output:I visually checked these occurrences and they are only indexed if they are not set to
None
, so I think it is acceptable to ignore these errors.