JetBrains / intellij-micropython

Plugin for MicroPython devices in PyCharm and IntelliJ
https://plugins.jetbrains.com/plugin/9777-micropython
Apache License 2.0
495 stars 106 forks source link

cannot find reference to 'STA_IF' in 'network.pyi' #241

Open waanito opened 11 months ago

waanito commented 11 months ago

environment: macos; pycharm professional 2023.1.3 & 4; esp32 devkit1 attached as /dev/cu.SLAB_USBtoUART; micropython plugin installed; micropython esp8266 selected in languages.

trying to connect to wifi works fine from REPL in PyCharm when entered directly in REPL after ESP32 is erased then flashed with micropython but as soon as I write a simple main as below in PyCharm to connect it brings up the error in the title. Same code works fine in two other IDEs tried...

import network
from time import sleep

def getwifi():
    sta_if = network.WLAN(network.STA_IF)
    sta_if.active(True)
    sta_if.connect('AP_name', 'AP_password')
    while not sta_if.isconnected():
        pass
    sleep(2)
    print('network config:', sta_if.ifconfig())
    sta_if.active(False)
    print('network config:', sta_if.ifconfig())

if __name__ == '__main__':
    getwifi()

inspection of micropython.network.pyi shows the only reference to STA_IF within comments suggesting code like above. inspection of esp8266.network.pyi shows STA_IF defined. FWIW attempted workaround by copying 'esp8266.network.pyi' to a user module and importing gets past the title error but produces a new error that 'typing' is not defined.

waanito commented 11 months ago

Screen Shot 2023-07-17 at 1 27 17 PM

andreluisos commented 4 months ago

Same issue. Have you figured it out, @waanito ?

acloaf commented 3 months ago

Following up to see if there is a resolution for this, I am also experiencing it.