Skip to content
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

Merged
merged 2 commits into from
Oct 10, 2021

Conversation

careyk007
Copy link
Contributor

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 remaining Anys 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:

adafruit_ssd1306.py:269: error: Value of type "Optional[bytearray]" is not indexable
adafruit_ssd1306.py:270: error: Value of type "Optional[bytearray]" is not indexable
adafruit_ssd1306.py:271: error: Unsupported target for indexed assignment ("Optional[bytearray]")
Found 3 errors in 1 file (checked 1 source file)

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.

@tannewt tannewt requested a review from FoamyGuy October 7, 2021 01:03
Copy link
Contributor

@FoamyGuy FoamyGuy left a 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.

adafruit_ssd1306.py Outdated Show resolved Hide resolved
adafruit_ssd1306.py Outdated Show resolved Hide resolved
adafruit_ssd1306.py Outdated Show resolved Hide resolved
adafruit_ssd1306.py Outdated Show resolved Hide resolved
@careyk007
Copy link
Contributor Author

@FoamyGuy Thanks for the review! I added the additional types and some import statements to make the types available.

Copy link
Contributor

@FoamyGuy FoamyGuy left a 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

@gamblor21 gamblor21 merged commit fcaf6a5 into adafruit:main Oct 10, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 13, 2021
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
@gamblor21 gamblor21 mentioned this pull request Oct 22, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants