circuitpython: tools/test-stub.sh broken. Only one of two tests actually fails
mypy -c 'import busio; b: busio.I2C; b.readfrom_into(0x30, b"")'
Is supposed to fail because readfrom_into()
needs to write into the buffer but is given a byte string. However, it doesn’t. WriteableBuffer includes two string types that break the whole thing. If you remove them, then the test will fail.
Running mypy on the typing module gives a clue in how it fails:
mypy circuitpython_typing
circuitpython_typing/http.py:16: error: Skipping analyzing "adafruit_requests": module is installed, but missing library stubs or py.typed marker [import-untyped]
circuitpython_typing/device_drivers.py:12: error: Skipping analyzing "adafruit_bus_device.i2c_device": module is installed, but missing library stubs or py.typed marker [import-untyped]
circuitpython_typing/device_drivers.py:12: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
circuitpython_typing/__init__.py:39: error: Name "rgbmatrix" is not defined [name-defined]
circuitpython_typing/__init__.py:40: error: Name "ulab" is not defined [name-defined]
circuitpython_typing/__init__.py:48: error: Name "rgbmatrix" is not defined [name-defined]
circuitpython_typing/__init__.py:49: error: Name "ulab" is not defined [name-defined]
circuitpython_typing/__init__.py:131: error: Name "audiocore" is not defined [name-defined]
circuitpython_typing/__init__.py:132: error: Name "audiocore" is not defined [name-defined]
circuitpython_typing/__init__.py:133: error: Name "audiomixer" is not defined [name-defined]
circuitpython_typing/__init__.py:134: error: Name "audiomp3" is not defined [name-defined]
circuitpython_typing/__init__.py:135: error: Name "synthio" is not defined [name-defined]
circuitpython_typing/__init__.py:141: error: Name "rgbmatrix" is not defined [name-defined]
circuitpython_typing/__init__.py:144: error: Name "alarm" is not defined [name-defined]
circuitpython_typing/socket.py:129: error: Name "_FakeSSLContext" is not defined [name-defined]
Found 14 errors in 4 files (checked 8 source files)
It seems we have a circular dependency between circuitpython_typing and circuitpython stubs.
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 15 (2 by maintainers)
Commits related to this issue
- Fix a couple of incorrect type annotations h/t @justmobilize in https://github.com/adafruit/circuitpython/issues/8891 — committed to jepler/circuitpython by jepler 5 months ago
@tannewt OMG. Realizing that
circuitpython_typing/socket.py
exists, means that we don’t need that defined inConnectionManager
code at all. And that kills a whole kb of thempy
. Technically we could also remove it fromRequests
now…If we actually add a
_FakeSSLContext
definition incircuitpython_typing/socket.py
, we can fix this bug now and remove all that typing code fromConnectionManager
Fixed the
try/except
by usingif TYPE_CHECKING
. Which looking is what seems to be common