Skip to content

Add type checking features and UI - #62

Open
Josverl wants to merge 10 commits into
vshymanskyy:mainfrom
Josverl:feat/type_checking
Open

Josverl wants to merge 10 commits into
vshymanskyy:mainfrom
Josverl:feat/type_checking

Conversation

@Josverl

@Josverl Josverl commented Aug 9, 2026

Copy link
Copy Markdown

Introduce a new type-checking service with

  • a diagnostics UI,
  • support for different checking modes,
  • integration with the editor and workspace lifecycle.

Adds dependencies and add a new Rollup loader.
Include tests for type-checking eligibility and expand localization for type-checking settings.

Currently I publish the components from github via immutable tags via the JSDeliver CDN
But intend to move to npm or similar - open to suggestions.

There is likely more fit and finish to do, I have tested against VMs and hardware, and have done my best to extend the test cases.

I have some documentation for the backend services that I want to push to RTD , for now it is in https://github.com/Josverl/stubs_playground/tree/integrate/docs

Closes: #4

@vshymanskyy

vshymanskyy commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Thanks for a valuable contribution. A few suggestions before we move any further:

  • a new Rollup loader could probably be eliminated once the packages are published to NPM
  • ensure that tests are passing - I have at least one failing at the moment.
  • I need to adjust GitHub actions to run tests on PRs - will do it ASAP
  • the imported modules are very noisy on the console.log - need to make it adjustable and more humble by default on production.
  • please move all typechecking* files into a separate folder
  • Type Check tab to be renamed to Diagnostics or Validation - TBD
  • mpy-cross validator emits messages starting with MicroPython: .... I think we should just set the diagnostic-source to mpy-cross now.
  • Autocomplete is not always shown after . is typed. Sometimes it requires to re-type it multiple times.
  • I think Typecheck FIles should be Opened by default. Users probably don't expect a full filesystem readout on connection. - TBD
  • The purpose of Install stubs from PyPI setting is unclear

Also, we should probably consider deduplicating reports from Ruff, mpy-cross and Pyright

@Josverl

Josverl commented Aug 10, 2026

Copy link
Copy Markdown
Author

Thanks for the initial review, I agree with most of the points above.

A few follow ups

Type Check tab to be renamed to Diagnostics or Validation

VsCode uses Problems, that or Diagnostics seems best.

mpy-cross validator emits messages starting with MicroPython: .... I think we should just set the diagnostic-source to mpy-cross now.

Agree, do you have an example how to trigger such a message?

Autocomplete is not always shown after . is typed. Sometimes it requires to re-type it multiple times.

I'll need to look into that. In the stubs playground client I remember I needed to do extra work on the merging and sorting of the rather poor suggestions from code mirrors python and the ones from pylance.
Perhaps that can be re-used.

I think Typecheck FIles should be set to Opened by default.

That was the intent, to avoid unexpected synchronisation from the device.

The purpose of Install stubs from PyPI setting is unclear

The goal is to allow installation of stubs of libraries such as emlearn-micropython from PyPi once @jonnor has published it.
Similar for Circuit python, that have a lot of stub packages for boards an stuff.
I was considering disabling/hiding that unless Advanced Mode is turned on.
It also needs some more work on the backend to provide a better list of relevant stubs, based on the board's information.

@vshymanskyy

vshymanskyy commented Aug 10, 2026

Copy link
Copy Markdown
Owner

"Problems" is fine

mpy-cross specific error (works on CPython, not in MicroPython):

print(0x1.to_bytes(1))

Using "Advanced Mode" and improving the suggestion for stubs selection is welcome!

@Josverl
Josverl force-pushed the feat/type_checking branch from 49baaf7 to 95402f2 Compare August 23, 2026 22:27
@Josverl

Josverl commented Aug 24, 2026

Copy link
Copy Markdown
Author

@tannewt, @dhalbert,

I'm working on adding static typechecking to ViperIDE and other similar MicroPython tools , mostly based on the micropython-stubs that I maintain,.
If this gets merged ViperIDE can autodetect a connected device - and switch to the most relevant stubs, or allow a user to select , or een install specific stubs or bundels from PyPI

I Have added stubs for CircuitPython
image
Based on the package currently on PyPI
"package": "circuitpython-stubs",
"package_version": "10.2.1",

But I want to check with you both if this is the correct package (as it is somewhat older than I expected) , and if you have other comments or suggestions wrt typing for CircuitPython .
If you think that CP should be omitted - that is fine as well.

@Josverl

Josverl commented Aug 31, 2026

Copy link
Copy Markdown
Author

@vshymanskyy and all others that may stumble on this.

All things that I set out to do work, but there also some things that want to look into a bit further. (scope creep ?)
Part if this is that the recent release of V1.29.0 made clear that static packing stub packages works - but also comes with limitations and impact on release interdependencies.

For anyone wanting to try:
I have published a beta at: ViperIDE Typing beta

Any feedback is appreceated.

@Josverl
Josverl force-pushed the feat/type_checking branch 3 times, most recently from 40dcd22 to ccc9495 Compare September 3, 2026 20:49
Add the pinned LSP client, Pyright worker, browser-test tooling, and matching runtime dependencies required by the type-checking integration.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Add local package resolution, worker and stub asset staging, and focused tests for building ViperIDE against sibling type-checking packages.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Add the browser type-checking service, runtime lifecycle, workspace mirror, verified stub selection, package installation and caching, and bundled Viper tools stubs with unit coverage.

Fold shutdown, retry, race, and workspace consistency fixes into the initial service implementation.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Add reviewed type-checking defaults, stub controls, localized Problems presentation, accessibility-aware severity filtering and counts, responsive styles, and unit coverage.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Add a shared input dialog and migrate standalone WebREPL and file prompt flows away from direct browser prompts.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Wire type checking into application controllers, CodeMirror editors, cached and device files, board metadata, completions, mpy-cross diagnostics, package prompts, and runtime restarts.

Preserve editor extensions and hide filtered diagnostics consistently across Problems and lint surfaces.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Add deterministic Playwright fixtures and helpers, migrate browser workflows, block unintended network access, provide opt-in live package tests, and run the suite in PR CI.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Install from lockfiles, preserve MicroPython-compatible minification, verify inlined assets, and version WebAssembly runtime URLs to avoid stale service-worker cache mismatches.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Add the beta Pages workflow and isolate deployment concurrency so beta builds cannot cancel production releases.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Document type-checking modes, runtime and stub selection, local package workflows, browser tests, and the provenance of bundled Viper tools stubs.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
@Josverl
Josverl force-pushed the feat/type_checking branch 2 times, most recently from 20e8afe to 542a79c Compare September 23, 2026 20:00

This branch has not been deployed

No deployments
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.

No micropython specific syntax highlights

2 participants