cpwood / Pico-Stub

MicroPython stubs for the Raspberry Pi Pico
Apache License 2.0
32 stars 6 forks source link

python.analysis.stubPath #10

Closed kevindawson closed 3 years ago

kevindawson commented 3 years ago

python.analysis.stubPath

Used to allow a user to specify a path to a directory that contains custom type stubs. Each package's type stub file(s) are expected to be in its own subdirectory.
Default value: ./typings

Pylance - gets confused, Pin & ADC with out above

from machine import Pin, ADC

settings.json

{
  "python.linting.enabled": true,
  "python.analysis.typeshedPaths": [".vscode/Pico-Stub"],
  "python.analysis.stubPath": ".vscode/Pico-Stub",
  "python.languageServer": "Pylance",
  "python.analysis.typeCheckingMode": "basic",
  "python.analysis.extraPaths": [
    ".vscode/Pico-Stub/stubs"
  ],
  "python.pythonPath": "/home/*****/.local/share/virtualenvs/Pico_py-RF1i-mIK/bin/python"
}
cpwood commented 3 years ago

Hi @kevindawson - I either can't reproduce this or I'm not understanding correctly, sorry.

I've started a new Python file in Pico-Go and have configured the project so it's using the Pico-Stub stubs:

settings.json is as follows:

{
    "python.linting.enabled": true,
    "python.analysis.typeshedPaths": [
        ".vscode/Pico-Stub"
    ],
    "python.languageServer": "Pylance",
    "python.analysis.typeCheckingMode": "basic",
    "python.analysis.extraPaths": [
        ".vscode/Pico-Stub/stubs"
    ]
}

First line of the Python file is:

from machine import Pin, ADC

I don't see anything confusing; linting and intellisense all seem fine.

Also, machine.pyi is already in its own folder:

image

Sorry if I'm missing something; can you please clarify?

kevindawson commented 3 years ago

@cpwood pylint & mypy would be my first choice in pycharm. But that is not going to happen soon with rp2.

In vscode I have been having issues with linting & types after switching over to pylance - not my first choice but much easer to use due to your efforts.

rp2-pico-20210313-unstable-v1.14-108-ge98ff3f08.uf2

after re-reading pylance info on git hub I think you need to add the additional settings

there seamed to be an improvement

nb. state.machines are still a pain in the rear at present regardless of which linter is used

the above is just sharing my critique with you

cpwood commented 3 years ago

If you'd prefer to use Pylint, this should help. When the stubs weren't part of Pico-Go, this is how I used to do it.

Regarding state machines, I know exactly what you mean. This is the best workaround for now, though I'd prefer to be able to disable linting for a specific method. Not possible at the moment, unfortunately.

kevindawson commented 3 years ago

@cpwood I was going through that erk-sum process - hence switch to pylance due to your efforts

You need a link on GitHub front page -> http://pico-go.net/docs/start/tips

cool -> #assembly-code-errors - works great nice and quite on the lint errors now

I like a lot of others I expect will go to a projects GitHub as first place to look for info. or read the code works if I have too.