Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy / pyright compatibility #9220

Closed
bendavis78 opened this issue May 3, 2024 · 2 comments
Closed

mypy / pyright compatibility #9220

bendavis78 opened this issue May 3, 2024 · 2 comments
Labels
bug support issues that involve helping a user accomplish a task tooling
Milestone

Comments

@bendavis78
Copy link

CircuitPython version

Installed in venv:

circuitpython-stubs==9.0.3
mypy==1.10.0
mypy-extensions==1.0.0
nodeenv==1.8.0
pyright==1.1.361
setuptools==69.5.1
typing_extensions==4.11.0

Code/REPL

n/a

Behavior

n/a

Description

My editor is configured to use pyright lsp and mypy for type checking. I'm working in a virtualenv with mypy, pyright, and micropython-stubs installed. I'm currently having the following issues:

pyright

$ pyright code.py
/home/ben/Projects/personal/circuitpy/code.py
  /home/ben/Projects/personal/circuitpy/code.py:3:8 - warning: Import "board" could not be resolved from source (reportMissingModuleSource)
  /home/ben/Projects/personal/circuitpy/code.py:4:8 - warning: Import "digitalio" could not be resolved from source (reportMissingModuleSource)
  /home/ben/Projects/personal/circuitpy/code.py:8:36 - error: "LED" is not a known attribute of module "board" (reportAttributeAccessIssue)
1 error, 2 warnings, 0 informations

It's unclear what other packages my editor needs installed for mypy linting and code completion.

mypy

$ mypy code.py
code.py:8: error: Module has no attribute "LED"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)

With mypy, I'm unable to resolve any attributes for the board and digitalio module.

Additional information

No response

@bendavis78 bendavis78 added the bug label May 3, 2024
@tannewt tannewt added tooling support issues that involve helping a user accomplish a task labels May 3, 2024
@tannewt tannewt added this to the Support milestone May 3, 2024
@tannewt
Copy link
Member

tannewt commented May 3, 2024

digitalio stubs are provided in https://pypi.org/project/circuitpython-stubs/ along with all of the other native modules. board is a special case because its contents change depending on the board. It takes extra setup: https://learn.adafruit.com/welcome-to-circuitpython/pycharm-and-circuitpython#device-specific-board-stubs-3168661

@dhalbert
Copy link
Collaborator

Closing for now. Please reopen if you have further questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug support issues that involve helping a user accomplish a task tooling
Projects
None yet
Development

No branches or pull requests

3 participants