Skip to content

Type hints for stdlib modules without a u prefix #361

@nickovs

Description

@nickovs

For a couple of years now (since this commit) the Micropython implementations of the standard libraries have been importable without needing a u prefix, so you can just import json or asyncio instead of ujson or uasyncio. This is now the preferred way to use these libraries, and their example code generally uses them this way. Unfortunately the current Intellij plugin does not recognise these imports as fetching the Micropython version, and it uses the type hints from the standard CPython libraries instead.

The Micropython versions of these libraries have some minor differences and extensions, so otherwise working code that say await asyncio.sleep_ms(100) gets flagged with a Cannot find reference 'sleep_ms' in '__init__.pyi' and if you remove the await then it fails to flag the Coroutine 'sleep_ms' is not awaited that it should.

It would be very helpful if the stub .pyi files were updated to provide Micropython-specific hints for the standard libraries under the standard names as well as with the u prefix, so that it properly hints code written in the now-preferred manner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions