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

[BUG] "h:\code.py" is overriding the stdlib module "code" #106

Open
rpgrunwald opened this issue Dec 12, 2022 · 4 comments
Open

[BUG] "h:\code.py" is overriding the stdlib module "code" #106

rpgrunwald opened this issue Dec 12, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@rpgrunwald
Copy link

rpgrunwald commented Dec 12, 2022

Describe the bug
Error message "h:\code.py" is overriding the stdlib module "code"

To Reproduce
Steps to reproduce the behavior:
Add CIRCUTPY drive with Open Folder
Open code.py

image

Desktop (please complete the following information):

  • OS: Windows 10 Version 10.0.19045 Build 19045
  • Visual Studio Code 1.74.0
  • vscode-circuitpython [0.1.19]

Additional context
Adafruit Circuit Playground Express with adafruit-circuitpython-circuitplayground_express-en_US-7.3.3.uf2

@rpgrunwald rpgrunwald added the bug Something isn't working label Dec 12, 2022
@IrregularShed
Copy link

This issue is unrelated to the extension. It's occurring due to the way the Pylance language server is configured; Pylance has no concept of CircuitPython or MicroPython and is attempting to treat what it has found in the same way as it would 'proper' Python. I had the same experience, and fixed it like this:

  • open Settings
  • search for Analysis: Diagnostic Severity Overrides to get straight to the correct setting
  • click Edit in settings.json, which should take you to the correct part of the settings.json file structure
  • this is what mine says now:
"python.analysis.diagnosticSeverityOverrides" : {
  "reportShadowedImports": "none"
}

Hope that helps!

@joshmarinacci
Copy link

This might be a good thing to add to the extension docs. I ran into it as well.

@stefan-sherwood
Copy link

According to the documentation:

CircuitPython looks for a code file on the board to run. There are four options: code.txt, code.py, main.txt and main.py. CircuitPython looks for those files, in that order, and then runs the first one it finds. While code.py is the recommended name for your code file, it is important to know that the other options exist.

So an arguably better solution is to name your main program file main.py instead of code.py. Then you'll still get (useful, IMO) warnings when you override modules but you won't have the problem reported here.

@VashJuan
Copy link

Much better solution (IMHO) is just to rename code.py to main.py: it won't conflict with the standard libraries & will still get run on boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants