Josverl / micropython-stubber

Generate and maintain stubs for different MicroPython ports to use with VSCode and Pylance, PyRight, Thonny, PyCharm or MyPy
https://micropython-stubber.readthedocs.io
Other
172 stars 14 forks source link

investigate/resolve 'import time' and 'import gc' issues #32

Closed Josverl closed 1 year ago

Josverl commented 3 years ago

workaround for sys and gc # pylint: disable=no-member

Module 'sys' has no 'print_exception' member Module 'gc' has no 'mem_free' member Module 'gc' has no 'threshold' member Module 'gc' has no 'mem_free' member Module 'gc' has no 'mem_alloc' member { "resource": "/c:/develop/MyPython/ESP32-P1Meter/src/main.py", "owner": "python", "code": "no-member", "severity": 8, "message": "Module 'gc' has no 'mem_free' member", "source": "pylint", "startLineNumber": 33, "startColumn": 22, "endLineNumber": 33, "endColumn": 22 }

Josverl commented 2 years ago

This was caused by a priority order conflict in pyright. this is now fixed in pyright and will be updated in Pylance as well. https://github.com/microsoft/pyright/issues/2937

this change however also exposes a few new issues where the generated firmware and document stubs do not work well, and where they add little value

The best option for this is to prevent these stubs to be created in both docstubs and in create_stubs Maintain lookup table in : src/rst/lookup.py - DOCSTUB_SKIP= List[string]

# docstubs generation, exclude stub generation for below stubs.
DOCSTUB_SKIP = [
    "uasyncio.rst",  # can create better stubs from frozen python modules.
    "builtins.rst",  # conflicts with static type checking , has very little information anyway
    "re.rst",  # regex is too complex
]

docstubs

createstubs

Josverl commented 1 year ago

Fixed by