Skip to content

Add type checking features and UI - #62

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

Add type checking features and UI#62
Josverl wants to merge 57 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 and others added 23 commits September 2, 2026 00:36
Add a restricted jsDelivr HTTPS-module Rollup loader with relative remote-import resolution and validation for URLs, redirects, responses, and JavaScript content types.

Bundle the tagged LSP client, consume the corrected diagnostics client, and pin the Pyright worker assets to the immutable v0.2.3 release.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the type-checking service boundary, worker asset loading, debounced diagnostics, device-aware stub selection, and serialized reconfiguration.

Support MicroPython VM stubs and PyPI stub package discovery, installation, persistence, and cache controls. Document the integration API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add persistent Basic, Standard, and Strict modes; automatic or manual board stubs; configurable workspace scope; and organized localized settings.

Expose type-check status and disable controls, and add a diagnostics panel that distinguishes live editor diagnostics from unopened workspace files.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bind Python editors to LSP compartments, synchronize and hydrate cached workspace files, and mirror device Python files when All scope is enabled.

Use device platform and build metadata for stub selection, preserve manual overrides, guard device reads when type checking is disabled, and expand workflow coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Removed the duplicate sizeOf method
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Includes support for translations.

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>
…al tabs

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
@mp-codemirror/lsp-client
@mp-codemirror/pyright-worker

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
The reusable client defaults typeshedPath to /typeshed-fallback, which is
CPython's typeshed, and ViperIDE never overrode it. MicroPython-specific
stdlib signatures were therefore reported as errors -- for example
json.dump(obj, fp, separators) is valid on MicroPython but rejected by
CPython's keyword-only signature -- and hover showed CPython documentation.

Pin typeshedPath to /typeshed-micropython so micropython-stdlib-stubs are
used, and take pyright-worker 0.4.0, which starts about 2.5x faster and
ships a 5.4 MB bundle instead of 8.7 MB.
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
- Updated typechecking_assets.js to support board stub package configuration.
- Enhanced typechecking_service.js to allow filtering of stub packages and added a new method for querying the stub package catalog.
- Modified typechecking_settings.js to build runtime configuration from published catalog packages.
- Added new localization keys for typecheck stub family, version, port, board, selected package, and not applicable.
- Improved unit tests to cover new stub package features and ensure correct behavior of typechecking settings.
- Updated diagnostics panel tests to reflect changes in typechecking mode and stub selection.

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>
…ages

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Josverl and others added 20 commits September 2, 2026 00:41
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Avoids a version mismatch between the loader
and a service worker's cached MicroPython N-1 WASM binary.

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
…nce build scripts

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c38c9917-3bfc-4b82-9321-90b3e57c84df
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c38c9917-3bfc-4b82-9321-90b3e57c84df
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
Startup resolved the stub package after Pyright reached ready and then
restarted the runtime, so completions and edits made in that window were
lost. Queued type-checking work now keeps the status busy until it drains.

Also declare the Python browser-test environment (pyproject test group,
uv.lock, test:browser script) and make two tests depend on explicit
configuration instead of a stale version literal and a transient state.
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>

/** localStorage key for last-known-good runtime metadata. */
const DEFAULT_RUNTIME_STORAGE_KEY = 'viperide-pyright-runtime-lkg'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this fallback to localhost not intruduce a risk ?
Why is it needed in the first place ?

- Updated .gitignore to include Viper tools stubs output.
- Added Viper tools stubs wheel to assets.
- Enhanced Development.md to document Viper tools stubs lifecycle.
- Modified eslint.config.mjs to include Viper tools stubs metadata.
- Updated rollup.config.mjs to copy Viper tools stubs during build.
- Added UI checkbox for including Viper tools stubs in ViperIDE.html.
- Updated app.js to manage Viper tools stubs setting.
- Translated new UI strings for Viper tools stubs in multiple languages.
- Enhanced typechecking_assets.js to handle Viper tools stubs metadata.
- Updated browser tests to verify Viper tools stubs functionality.
- Added unit tests for Viper tools stubs integration in typechecking_assets.js.

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>
Allows connection to versions/varionst that do not support `"".hex()`

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
…pe checking resources

Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
- Add a reusable input dialog to handle user input for WebREPL connection and file creation.
- Update bridge.html to include the new dialog and refactored connection logic to utilize it.
- Modify control_client.js to streamline connection handling and remove direct prompt usage.
- Enhance viper_lib.js to export the new requestUserValue function for dialog interactions.
- Update tests to verify dialog functionality for WebREPL connections and file creation.
- Add new tests for package installation dialog interactions.

Fixes: vshymanskyy#63
Signed-off-by: Jos Verlinde <Jos_Verlinde@hotmail.com>
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