paulober / MicroPico

MicroPico (aka Pico-W-Go) is a Visual Studio Code extension designed to simplify and speed up the development of MicroPython projects for the Raspberry Pi Pico and Pico W boards.
https://marketplace.visualstudio.com/items?itemName=paulober.pico-w-go
Mozilla Public License 2.0
295 stars 27 forks source link

RP2040 NeoPixel `__setitem__` is missing #264

Closed DeflateAwning closed 2 days ago

DeflateAwning commented 1 week ago

The NeoPixel example from the MicroPython rp2 docs is as follows:

from machine import Pin
from neopixel import NeoPixel

pin = Pin(0, Pin.OUT)   # set GPIO0 to output to drive NeoPixels
np = NeoPixel(pin, 8)   # create NeoPixel driver on GPIO0 for 8 pixels
np[0] = (255, 255, 255) # set the first pixel to white
np.write()              # write data to all pixels
r, g, b = np[0]         # get first pixel colour

The example gives a warning on the np[0] = (255, ...) line, because it can't find the __setitem__ method of the NeoPixel class.

Josverl commented 5 days ago

You are correct that the type stubs are incomplete here. I'm aware of this and tracking it. I'm doing a significant change to to add overloads to the stubs, and the fix to this will follow that one.

The code will run, but you may want to add a # type:ignore for now.

https://github.com/Josverl/micropython-stubs/issues/764

DeflateAwning commented 2 days ago

Ah oops, I totally opened that on the wrong repo; my bad. Thanks a lot!