DetachHead / basedpyright-playground

Website for testing snippets of code using the basedpyright type checker
https://basedpyright.com
MIT License
5 stars 1 forks source link

suggested `typing_extensions` import doesn't exist #20

Open jorenham opened 3 months ago

jorenham commented 3 months ago

I just tried out the (awesome) new client-side playground, and found a tiny bug, which actually would be a nice feature:

image

So I decide to do what I'm told, and import typing_extensions, after which I'm told that

Import "typing_extensions" could not be resolved from source (reportMissingModuleSource)

I first guessed that it has to do with typeshed's stdlib stubs, which contain the typing_extensions.pyi phantom stubs. But it turns out that I'm missing something, because _typeshed (also a typeshed phantom), actually imports without error 🤔:

https://basedpyright.com/?typeCheckingMode=all&reportUnusedImport=true&code=JYWwDg9gTgLgBAOwK7gJ5zgYjgYwDYCmAhlHugCYQEDOCA5PAQB7DUwBQokscMqYwBAHMA%2BsxgEE1YBCkZsbJACNqAWlllO4aPBF8wNABYFy8uADpLAfiA

Either way, I think it would be helpful to have typing_extensions available although I have no idea how, because I didn't see a (c)python runtime i.e. no search results came up for "pyodide".

DetachHead commented 3 months ago

hmm maybe i should just disable reportMissingModuleSource in the playground, but i don't really want to introduce different behavior in the playground so idk

jorenham commented 3 months ago

I know that pyodide can dynamically load python packages in-browser using micropip. So maybe that could be used here.

That also opens the door to loading arbitrary packages. When I'm numpy when I'm working on numpy's typing stubs, I often tend to go to the basedpyright playground, only to realize that there's no numpy there; but maybe that's just me 🤷🏻. The same goed for optype btw. Anyway, I think it would be very helpful to be a able to install packages into the playground.

Having a runtime available would also be helpful I think. That way you can verify if your typing examples match up with the runtime, and check that it actually runs.