Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pycharm false alarm: Unresolved attribute reference 'toggle' for class 'Pin' #319

Open
Omid888 opened this issue Aug 2, 2024 · 6 comments

Comments

@Omid888
Copy link

Omid888 commented Aug 2, 2024

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.

@lancelote
Copy link
Member

the code works correctly on the microcontroller

Would you kindly specify the board?

@Omid888
Copy link
Author

Omid888 commented Aug 3, 2024

@lancelote

raspberrypi pico
micropython version: 1.23.0

@Omid888
Copy link
Author

Omid888 commented Aug 3, 2024

import onewire has this problem too.

@lukaskremla
Copy link

lukaskremla commented Aug 13, 2024

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

@Omid888
Copy link
Author

Omid888 commented Aug 16, 2024

@Josverl Do you have any suggestions?

@Josverl
Copy link
Contributor

Josverl commented Aug 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants