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
175 stars 14 forks source link

Add snippet tests using mypy #445

Closed Josverl closed 9 months ago

Josverl commented 11 months ago

The Goal is to run mypy across all check and feature folders by re-use the same approach as for the pyright snippet test.

Parsing mypy output There is no simple way to get machine readable output from mypy

workaround: regex hack in the mypy-vscode extension:

import re

pattern = r'^(?P<file>[^:\n]+):((?P<line>\d+):)?((?P<column>\d+):)? (?P<type>\w+): (?P<message>.*)$'

Changes to stubs: One challenge is that mypy does not allow a replacement stdlib to be used , at least not for all modules. Specificaly the sys.pyi module seems to be a blocker as mypy just refuses to run if it is included. A simple /blunt approach would be to just delete the typings/sys.pyi file before running the test.

Josverl commented 9 months ago

implemented in : https://github.com/Josverl/micropython-stubs/pull/739