The structure of a stubs installation #775
Replies: 3 comments 1 reply
-
First of all, on the stub structure - ive learning and hacking workarounds as I built them over the years, model 1the stubs were still .py files , which makes the type checkers work differently ( as I found out much later) model 2each stub had its own copy of `os model 3I introduced this with the micropython-stdlib-stubs as before that the typecheckers just ignored the stubs for any of the stdlib librarries, I added a hack to not need to reverse engineer / rewrite the _typeshed stubs for stdlib :
the hack works somewhat - but not for all typecheckers and linters. model 4and
Model 5Im currently working on an update to:
This is still a work in progress , and I had hoped to complete it for the 1.24.x release of micropython - but Im still working through some issues in auto generating stubs in this manner. I hope to have it ready in the next few weeks, but creating code that can merge source files in a clear and consistent way is tens to turn up new surprises quite frequently. Model 6 - Structure of a stub package ( todo)Then there is one other thing, apparently I misread PEP 561 ( or it was written to be understood by people that already understood it ) |
Beta Was this translation helpful? Give feedback.
-
It looks like I underestimated the complexity of the problem. I had only focused on Pyright, but now I see that MyPy has its own requirements about typeshed and also uses different import resolution order. I made some experiments but ended up more confused than before: https://discuss.python.org/t/foo-vs-foo-stubs-with-mypypath/77314 I suppose you have already tried it, but out of curiosity -- what would happen if you replaced the content of stdlib/os/init.pyi (the one containing extra methods) with the content of os.pyi? |
Beta Was this translation helpful? Give feedback.
-
I've been working on improving the mypy support as it had problems with the MicroPython-stdlib. I plan to publish these in the next week, only for V1.24.1 and newer. Part of that work was to remove most of the duplicates between modules such as typings/foo and typings/stdlib/foo I need to check if there is additional duplication I can remove. HTH |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First, thanks for this effort!
I'm curious about the structure of the files and folders in the installation target directory.
Let's say I do
pip3 install micropython-rp2-rpi_pico_w-stubs --no-user --target ./typings
I see that
typings/os.pyi
is a small file describing a subset of CPython's os module, but there's alsostdlib/os
, which seems to describe CPython's os.os
-stubs?stdlib/os
meant to be activated viatypeshedPaths
Pyright setting andos.pyi
viastubsPath
setting?stdlib/os
stubs? I understand that extra members don't harm diagnostics, but they do obstruct discovering available members during code completion.Beta Was this translation helpful? Give feedback.
All reactions