Skip to content

Conversation

@jolaf
Copy link

@jolaf jolaf commented Jan 5, 2026

I'm writing a PyScript app, and I see a lot of situations where the stubs are incorrect and incomplete.
After struggling for some I've decided to do something with it and updated the stubs so that they've become effective for my projects.
They're still incomplete but less incomplete than before.

@Josverl
Copy link

Josverl commented Jan 6, 2026

Hi @jolaf ,

Thanks for the contributions,

To help with the review can you specify which version and runtime of pyscript you have based and verified your changes on?

I also have an update stewing, and I want to prevent that undoing parts of your work

@jolaf
Copy link
Author

jolaf commented Jan 6, 2026

I'm working with PyScript 2025.11.2.
And typechecking statically with mypy 1.19.1 and in runtime with beartype 0.22.9.

Copy link

Choose a reason for hiding this comment

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

stub-only packaged should not contain a py.typed marker file.

Copy link

Choose a reason for hiding this comment

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

the _typeshed.pyi stub is already available in all typecheckers and should not be overwritten from this package.
doing that will likely disrupt all static typecheckers and IDE;s

ref : https://github.com/python/typeshed/blob/main/stdlib/_typeshed/__init__.pyi

# Copyright (c) 2020-2025 Jos Verlinde
# MIT Licensed

__all__ = [
Copy link

Choose a reason for hiding this comment

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

what is the purpose of removing __all__ ?

removing it will expose module attributes that are not public , or not actually available at runtime.
I know it is a bit of a hassle to add to it , but that is part of the price to pay for stability and reliability,

@@ -0,0 +1,14 @@
from __future__ import annotations
Copy link

Choose a reason for hiding this comment

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

l suggest to to add a docstring here that this submodule is (AFAIK) only available python/pyodide and not to MicroPython

(currently it is not yet possible for typecheckers / IDEs to filet on this , so we need to communicate this in a human readable manner.

Copy link

Choose a reason for hiding this comment

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

the should not be any py.typed in stub only packages.

Copy link

Choose a reason for hiding this comment

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

no py.typed

"""

def __init__(self, name, error) -> None: ...
def __init__(self, name: str, error: BaseException) -> None: ...
Copy link

Choose a reason for hiding this comment

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

Is there a special reason you need BaseExeption rather than the normal Exception ?

from js import Event as JsEvent, FileList

from .events import Event
from ._typeshed import Incomplete
Copy link

Choose a reason for hiding this comment

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

why not just _typeshed ?
._typeshed is not needed, unclear and risky

Copy link

@Josverl Josverl left a comment

Choose a reason for hiding this comment

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

I think there are a large number of very good improvements.
I have made a number of comments on things that I think should be changes , and question on the changes that I did not understand the pupose of.

To keep track of version specific changes - it may be useful to add a #version_comment

I did not do a full verification test - but I will likely need to update that test to the updated interfaces as well.

See: https://github.com/Josverl/micropython-stubs/tree/main/tests/quality_tests/check_webassembly

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.

2 participants