Josverl / micropython-stubs

Stubs of most MicroPython ports, boards and versions to make writing code that much simpler.
https://micropython-stubs.readthedocs.io
MIT License
153 stars 22 forks source link

esp32 related pylint errors #530

Closed ancebfer closed 2 years ago

ancebfer commented 2 years ago

I'm new to micropython-stubs and I don't know if this is a real issue with the stubs or it is a bad configuration of my environment.

I'm using MicroPython v1.18 with ESP32 board and the master branch of micropython-stubs.

My .pylintrc configuration is:

[MASTER]
init-hook='import sys;sys.path[1:1] = ["../micropython-stubs/cpython_core-micropython", "../micropython-stubs/micropython-v1_18-frozen/esp32/GENERIC", "../micropython-stubs/micropython-v1_18-esp32"];'

[MESSAGES CONTROL]
confidence=
disable=

If I check this test.py program with "pylint test.py":

from utime import time, localtime, ticks_ms, ticks_add

now = time()
ltime = localtime(now)
print(ltime)

tickref = ticks_ms()
tickref = ticks_add(tickref, 1000)
print(tickref)

I get this errors:

************* Module test
source/test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
source/test.py:1:0: E0611: No name 'time' in module 'utime' (no-name-in-module)
source/test.py:1:0: E0611: No name 'localtime' in module 'utime' (no-name-in-module)
source/test.py:1:0: E0611: No name 'ticks_add' in module 'utime' (no-name-in-module)

I don't guess why E06xx errors appear because "micropython-stubs/micropython-v1_18-esp32/utime.py" defines:

def localtime(*args, **kwargs) -> Any:
    ...

def ticks_add(*args, **kwargs) -> Any:
    ...

def ticks_ms(*args, **kwargs) -> Any:
    ...

def time(*args, **kwargs) -> Any:
    ...

Under vscode I get the same result using this "settings.json" configuration:

{
    "python.languageServer": "Pylance",
    "python.analysis.diagnosticMode": "workspace",
    "python.analysis.extraPaths": [
        "../micropython-stubs/cpython_core-micropython",
        "../micropython-stubs/micropython-v1_18-frozen/esp32/GENERIC",
        "../micropython-stubs/micropython-v1_18-esp32"
    ],
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true
}

Is this an issue with micropython-stubs or is there any mistake in my configuration?

Best regards.

Josverl commented 2 years ago

Hi, I'm currently on a break without a computer so can't really verify at this time.

I know pyright recently changed the resolution order to avoid the false warnings for time sys, gc and several other modules. Not sure if that has propagated into pylance yet.

I see no obvious mistakes in the configs.

On the pylint errors, I did find that pylint threw more false positives than pylance, so personally I switched it off, or disabled quite a few error classes