Skip to content

Conversation

@dhalbert
Copy link
Contributor

@dhalbert dhalbert commented Nov 12, 2025

The adafruit_esp32spi library (and a few others) have a redundant module naming structure that looks like this:
adafruit_esp32spi/adafruit_esp32spi.py, which means you usually do from adafruit_esp32spi import adafruit_esp32spi.

I have always found the duplicate name confusing. By adding from adafruit_esp32spi import *in __init__.py you can now just do import adafruit_esp32spi and have direct access to the definitions.

adafruit_esp32spi_socketpool.py and adafruit_esp32spi_wifimanager also have unnecessary prefixes on their names, which could just be socketpool.py and wifimanager.py I added such files that also do from ... import * to allow this.

So with this PR, you can now do:

import adafruit_esp32spi
from adafruit_esp32spi.socketpool import SocketPool
from adafruit_esp32spi.wifimanager import WiFiManager

control = adafruit_esp32spi.ESP32_SPIControl(...)

etc.

I changed all the examples/ file to use the shorter import names. After this is merged Learn Guide code can be changed. But since it's backwards compatible, that doesn't need to be done all at once.

I would release this as 10.1.0 or even 11.0.0. (Any opinion on that?)

Eventually we might remove the backwards compatibility.


I am working a native module version of adafruit_esp32spi in core CircuitPython, and removing this extra layer of naming simplifies the code notably. My plan would be to only support the newer naming scheme here.

@dhalbert dhalbert requested review from a team and FoamyGuy November 12, 2025 21:18
@dhalbert dhalbert marked this pull request as draft November 12, 2025 21:24
@dhalbert
Copy link
Contributor Author

I realized I need to explain this in the documentation, and also make sure the documentation builds properly with these from x import * references, so making this a draft for now.

@dhalbert dhalbert marked this pull request as ready for review November 13, 2025 14:39
@dhalbert
Copy link
Contributor Author

OK, undrafted and ready for review.

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.

This looks good to me. I tested the updated library on Fruit Jam with the IRC app and requests simpletest. I confirmed both old and new imports are working as expected and looked at the updated docs built locally.

Thank you for the simplification!

@dhalbert dhalbert merged commit dc617df into adafruit:main Nov 13, 2025
1 check passed
@dhalbert dhalbert deleted the shorter-imports branch November 13, 2025 16:03
adafruit-adabot pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 14, 2025
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