How to get stubs to work for gc? #13629
Replies: 2 comments 1 reply
-
A: Depends on the IDE and typechecker used background - stubs for stdlib modules are handled differently than other stubs , some typecheckers can be configured(pyright/pylance) , some just can't deal and bail out unless you delete some files (mypy). And some just work but mix Micro and C Python for edge cases (pycharm). I usually do not install the stubs into a .venv , but to a typings folder ( the default for pylance/pyright) The key ingedient is the
[tool.pyright]
include = ["."]
ignore = ["**/typings"]
exclude = [
".*",
"__*",
"**/typings",
]
typeCheckingMode = "basic"
stubPath = "typings"
typeshedPath = "typings"
pythonPlatform = "Linux"
reportMissingModuleSource = "none"
reportUnnecessaryTypeIgnoreComment = "error"
[tool.mypy]
platform = "linux"
mypy_path = "typings"
files = "*.py"
exclude = [
"typings[\\/].*",
]
follow_imports = "silent"
follow_imports_for_stubs = true
no_site_packages = true
check_untyped_defs = true
disable_error_code = ["no-redef","assignment"]
# snippets may re-use the same variable names
allow_redefinition = true
|
Beta Was this translation helpful? Give feedback.
-
You can do similar with the path adjusted for (on mobile, so no exact details) |
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.
-
I am using vscodium and using micropython for a project. I installed stubs for my port with
pip install micropython-esp8266-stubs
into a venv, which i set my project to use that venvs interpreter, which seemed to work great at first. But then i wanted to use thegc.threshold()
function and noticed i wasn't getting auto complete for it, or hints about the function signature or arg types.Right clicking on the gc import statement and "go to definition" shows me that the jedi language server is loading the stdlib stubs instead of the micropython ones. I've put in an issue to that project and they said that was a performance decision and sorry, fair enough.
but i was looking for a workaround and i was hoping i could just put the
gc.py
implementation from micropython into my project and import it with a relative path to force my IDE to know about the functions, but i couldn't find thegc.py
file, only thegc.c
file. Which im guessing is correct, i guess micropython isn't a library its an interpreter and those functions are baked in?So really what im trying to get help with, is how do we get our IDE's to show us the correct stubs for micropython? is this an issue specific to vscodium? (because we can't use pylance) or have others hit this issue and quietly found their own work arounds?
Any information or help would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions