Skip to content

Add typing support and enhance testing for runtime features#19310

Draft
Josverl wants to merge 13 commits into
micropython:masterfrom
Josverl:runtime_typing
Draft

Add typing support and enhance testing for runtime features#19310
Josverl wants to merge 13 commits into
micropython:masterfrom
Josverl:runtime_typing

Conversation

@Josverl
Copy link
Copy Markdown
Contributor

@Josverl Josverl commented Jun 4, 2026

Summary

This is a companion Draft-PR to micropython/micropython-lib#1051

The goal is to Introduce typing modules to MicroPython, to enabling support for various static typing features.
This PR manly consists of test for both supported an unsupported typing functionalities

It also includes:

  • Changes to tests/run-tests.py to support unittest@0.11.0
  • a new reporting tool tools/make-report.py
  • Addition of the typing modules to the unix-coverage variant.
  • several minor fixes.
  • Several temporary variants to aid in measurement and testing:
    • temporary unix-typing_XX variants to help gauge the size impact of freezing typing modules
    • temporary PYBV11-typing_XX variants to help gauge the size impact of freezing typing modules

I expect that this PR may be split and changed

Testing

The main part of this PR are tests , and test tools.

Tests were added to verify the runtime behavior of type annotations across various features. These tests were executed on the Unix port, and against multiple raw-iron boards.

Trade-offs and Alternatives

Inclusion of typing modules may increase code size, but it significantly enhances the functionality and usability of MicroPython for type hinting and static analysis.

Generative AI

I used generative AI tools when creating this PR, but a human has checked and corrected the
code and is responsible for the code and the description above.

Josverl added 13 commits June 2, 2026 21:33
See PR:  micropython/micropython-lib#1115

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
metaclasses, user-defined generics, get_args, get_origin,
runtime_checkable, and TypedDict

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Parse the expected failures (xfail) and unexpected passes (xpass)
if they are returned by MicroPython unitest.

An expected failure is treated as a pass
and Unexpected pass is a failure

This allows tests to specify more details on test outcomes.
Based on :
https://docs.python.org/3/library/unittest.html

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
#skipping-tests-and-expected-failures
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.47%. Comparing base (dc33f04) to head (58e8b73).
⚠️ Report is 71 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19310   +/-   ##
=======================================
  Coverage   98.47%   98.47%           
=======================================
  Files         176      176           
  Lines       22845    22845           
=======================================
  Hits        22497    22497           
  Misses        348      348           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Code size report:

Reference:  samd/mphalport: Run events at least once in mp_hal_delay_ms. [af38ee1]
Comparison: tools/manifestfile: Do not freeze manifest.py files. [merge of 58e8b73]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:  +152 +0.018% standard[incl +64(data)]
      stm32:    +0 +0.000% PYBV10
      esp32:   +64 +0.004% ESP32_GENERIC[incl +64(data)]
     mimxrt:    +0 +0.000% TEENSY40
        rp2:   +56 +0.006% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:  +680 +0.149% VIRT_RV32

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant