-
Notifications
You must be signed in to change notification settings - Fork 35
Importing versions >=1.10.3 broken in CPython #93
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
Comments
I'm fairly sure CPython includes its own requests library which works well. Is this a dependency of some library you are trying to use? |
My use case is that I'm developing a simulator for CircuitPython projects that runs project code in CPython (similar to Device Simulator Express but without being coupled to VSCode and having an additional goal to enable automated testing of CircuitPython projects in the simulator). The first board this simulator supports is the MagTag, and the Adafruit_CircuitPython_MagTag library which many MagTag projects use depends on But I think this issue also impacts any CircuitPython projects which depend on |
That project you are working on @kevincon sounds awesome! Blinka projects on RasPi or similar devices that are running CPython would have access to the "standard" python requests library, and they'd likely benefit from using that instead of the CircuitPython one which is designed as a subset of the standard one. I think It would be good to get it back to being able to imported on CPython nonetheless though because some of the files in this repo in I am still a bit new to the various ways to use typing in python. It does look like your proposed idea to use protocols could be a good solution to me. If you're interested in submitting a PR that would be awesome. If not I'll add this to my list and circle back to it at some point to attempt that change. In the meantime installing those extra libraries (and modifying requirements.txt if you'd like) are probably the easiest things to do to get it working. |
Awesome. Perhaps you can figure out some of the issues that affect the CircuitPython library. |
Thanks @FoamyGuy, while I agree that projects that aim to only run on Raspberry Pi and similar devices can use I'll work on making a PR to fix this and also try to incorporate importing |
Some of the imports introduced in #87 (released in version 1.10.3) appear to break the import of
adafruit_requests
in CPython due to those new imports not being part of theadafruit_requests
package's requirements.To reproduce, you can create a fresh virtual environment and install
adafruit-circuitpython-requests==1.10.4
:And then try importing
adafruit_requests
in the interpreter:I believe one of the imports of
adafruit_esp32spi
,adafruit_wiznet5k
, etc. in thistry
block fail withImportError
since they are not requirements ofadafruit-circuitpython-requests
and thus don't get installed bypip
, so theSocketType
type var does not get defined (hence the error above):Adafruit_CircuitPython_Requests/adafruit_requests.py
Lines 41 to 68 in 26b2411
but since the
try
block's exception handlerpass
es onImportError
, we don't see an error until the first attempted usage ofSocketType
in this type annotation:Adafruit_CircuitPython_Requests/adafruit_requests.py
Line 114 in 26b2411
I read on Discord someone else ran into this as well: https://discord.com/channels/327254708534116352/537365702651150357/925282376525959229
Since those
adafruit_esp32spi
,adafruit_wiznet5k
, etc. packages don't seem to be used beyond defining theSocketType
,InterfaceType
, etc.TypeVar
s, could protocols be used to define the shape of those types to avoid needing to import those packages?The text was updated successfully, but these errors were encountered: