8000 Define I2C if busio.I2C import fails by ilario · Pull Request #39 · adafruit/Adafruit_CircuitPython_INA219 · GitHub
[go: up one dir, main page]

Skip to content

Define I2C if busio.I2C import fails #39

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 8000 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

Merged
merged 1 commit into from
May 27, 2025

Conversation

ilario
Copy link
Contributor
@ilario ilario commented Mar 27, 2025

busio.I2C gets imported only for the type hint here:

class INA219:
    [...]
    def __init__(self, i2c_bus: I2C, addr: int = 0x40) -> None:

If the import of busio.I2C fails, then the definition of INA219 fails with:

NameError: name 'I2C' is not defined

So, instead of passing, I assign a None value to I2C simply for avoiding that error.

This PR is similar to this one done for another module: adafruit/Adafruit_CircuitPython_ADS1x15#93

@ladyada ladyada requested a review from FoamyGuy May 26, 2025 23:10
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.

Thank you!

@FoamyGuy FoamyGuy merged commit 1cce6de into adafruit:main May 27, 2025
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 28, 2025
Updating https://github.com/adafruit/Adafruit_CircuitPython_EPD to 2.13.4 from 2.13.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_EPD#88 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_INA219 to 3.4.28 from 3.4.27:
  > Merge pull request adafruit/Adafruit_CircuitPython_INA219#39 from ilario/importerror_i2c

Updating https://github.com/adafruit/Adafruit_CircuitPython_INA3221 to 1.2.0 from 1.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_INA3221#8 from BZab/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_OPT4048 to 1.0.1 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_OPT4048#1 from FoamyGuy/use_properties

Updating https://github.com/adafruit/Adafruit_CircuitPython_OV5640 to 1.2.8 from 1.2.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_OV5640#40 from FoamyGuy/saturation_effect_fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1322 to 1.4.5 from 1.4.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1322#25 from FoamyGuy/displayio_api_update

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1327 to 1.4.5 from 1.4.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1327#27 from adafruit/update-display-modules

Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1680 to 2.0.2 from 2.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_SSD1680#32 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7735 to 1.2.17 from 1.2.16:
  > Merge pull request adafruit/Adafruit_CircuitPython_ST7735#23 from FoamyGuy/displayio_api_update

Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X to 1.2.4 from 1.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_VL53L1X#25 from apzerafa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Dash_Dis to 3.0.2 from 3.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Dash_Dis#22 from adafruit/dhalbert-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 3.3.0 from 3.2.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#220 from cinderblockgames/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 4.1.11 from 4.1.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#213 from justmobilize/204-fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_OPT4048
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
0