intellij-micropython
intellij-micropython copied to clipboard
Pycharm false alarm: Unresolved attribute reference 'toggle' for class 'Pin'
Pycharm throws a warning for this working code:
from machine import Pin
from time import sleep
some_led = Pin(25, Pin.OUT)
while True:
some_led.toggle()
sleep(1)
Although the code works correctly on the microcontroller, pycharm could not understand the toggle() function and shows this warning:
Unresolved attribute reference 'toggle' for class 'Pin'
Since other IDEs (vscode & thonny) does not have this problem, I reached out to report it.
P.S: As you have probably guessed, pycharm's auto-completion does not work for this function, but it works for other functions.
the code works correctly on the microcontroller
Would you kindly specify the board?
@lancelote
raspberrypi pico micropython version: 1.23.0
import onewire has this problem too.
There is a similar issue with const, which has to be imported as from micropython import const to make PyCharm errors go away, works perfectly fine on the micro controller regardless of the import.
ESP32 S2
@Josverl Do you have any suggestions?
I'm assuming that you use the micropython-stubs for this, and followed the pycharm config for it
Please note that the stubs provided by the pycharm feature are different, and older, although there is some shared work here, there will be differences.
const is indeed a builtin that does not need an import on micropython, and for pylance/py right this can be configured through a __builtin__.pyi stub.
I have not yet found a way to configure the same in pycharm.