adafruit / Adafruit_CircuitPython_RTTTL

Play RTTTL tunes in CircuitPython
MIT License
4 stars 12 forks source link

NameError on Import #26

Closed bhclowers closed 2 years ago

bhclowers commented 2 years ago

Using circuitpython 7.0 (https://circuitpython.org/board/seeeduino_wio_terminal/) on the Wio Terminal, I run into an error with the adafruit_rtttl.mpy downloaded from https://circuitpython.org/libraries specific for 7.0 .

The specific error is:

Traceback (most recent call last): File "code.py", line 3, in File "adafruit_rtttl.py", line 158, in NameError: name 'Optional' is not defined

Any ideas on how to get things rolling?

FoamyGuy commented 2 years ago

I think we cannot add typing hints for variables such as these lines:

https://github.com/adafruit/Adafruit_CircuitPython_RTTTL/blob/fb3a0dc5ccdbea232cde2a97802d562ce538cfcf/adafruit_rtttl.py#L158-L160

I think that is supported in CPython but maybe not in CircuitPython since we don't have the typing module.

I will test out this theory and make a PR to resolve it for this library if my hunch is correct.

FoamyGuy commented 2 years ago

Ah I was a bit mistaken. These are not "regular" variables they are arguments in a function. My understanding is that CircuitPython should be ignoring them. Not sure why it's trying to actually use Optional but it does make sense that it would raise an exception if it is since there is no typing module. It should still be a relatively easy fix though I think. Doing a little more troubleshooting then I'll make a PR.