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

Add typing and required imports #24

Merged
merged 3 commits into from
Oct 28, 2021
Merged

Add typing and required imports #24

merged 3 commits into from
Oct 28, 2021

Conversation

tekktrik
Copy link
Member

No description provided.

@tekktrik tekktrik mentioned this pull request Oct 24, 2021
2 tasks
@tekktrik
Copy link
Member Author

Addressed issues from pre-commit

@kattni kattni requested a review from FoamyGuy October 27, 2021 20:43
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 @tekktrik

I think we want to put the imports inside of a try/except block like this:

try:
    # Used only for typing
    import typing
    from busio import I2C
    from time import struct_time
except ImportError:
    pass

This way the imports will not happen when it runs on the microcontroller which will end up saving some RAM.

@tekktrik
Copy link
Member Author

That makes sense, so anything not functionally necessary (just for typing) won't actually get called because of the ImportError on typing? I'm doing a few other repos, so just want to make sure I understand correctly. Thanks for the feedback!

@FoamyGuy
Copy link
Contributor

That makes sense, so anything not functionally necessary (just for typing) won't actually get called because of the ImportError on typing?

Yep that is correct. Importing anything from typing will raise the exception on microcontroller since there is no built-in typing module in CircuitPython.

@tekktrik
Copy link
Member Author

There's another library I'm working on that needs typing that doesn't use anything from the typing module, how would I handle that, since adding it makes the pylint fail? Is that still okay?

See adafruit/Adafruit_CircuitPython_74HC595#19 for reference

@tekktrik
Copy link
Member Author

Made edits per review

@tekktrik tekktrik requested a review from FoamyGuy October 28, 2021 03:12
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.

@FoamyGuy FoamyGuy merged commit 2257af3 into adafruit:main Oct 28, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 29, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 2.2.9 from 2.2.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#73 from tekktrik/feature/add-typing
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check
  > Moved default branch to main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP_ATcontrol to 0.5.8 from 0.5.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP_ATcontrol#44 from PontusO/revert-41-main
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP_ATcontrol#45 from jsymons/typing
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP_ATcontrol#46 from adafruit/not-using-with
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check

Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.9.4 from 3.9.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#69 from theendlessriver13/add-tests
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#70 from theendlessriver13/fix-byte-indexing

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8523 to 1.5.6 from 1.5.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCF8523#24 from tekktrik/feature/add-typing
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check
  > Moved default branch to main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template

Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.4.1 from 2.4.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#34 from ronnie-llamado/feature/add-type-annotations
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check
  > Moved default branch to main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template
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.

2 participants