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.

Activity

nickovs

nickovs commented on May 15, 2025

@nickovs
Author

Upon closer inspection, it looks like this is fixed for some but not all modules. asyncio is notably missing.

added a commit that references this issue on May 15, 2025
3944063
linked a pull request that will close this issue on May 15, 2025
Josverl

Josverl commented on May 18, 2025

@Josverl
Contributor

Apologies - I was misstaken.
This is a copy of Howard's stubs that he improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Josverl@nickovs

      Issue actions

        Type hints for stdlib modules without a `u` prefix · Issue #361 · JetBrains/intellij-micropython