micropy-cli icon indicating copy to clipboard operation
micropy-cli copied to clipboard

Windows install has pylint issue finding stubs

Open MilesStarr opened this issue 1 year ago • 1 comments

My first code showed import machine in error resulting in:

Unable to import 'machine' pylint(import-error) [Ln 3, Col 1]

pylint should be able to find the stub information.

in .pylintrc template:

init-hook='import sys;sys.path[1:1]=["src/lib",{% for path in paths %}"{{ path|replace("\\", "/") }}", {% endfor %} ]'

resulted in:

init-hook='import sys;sys.path.insert(1, ".micropy\micropy-cli\frozen");sys.path.insert(1, ".micropy\BradenM-micropy-stubs-4f5a52a\frozen");sys.path.insert(1, ".micropy\micropy-cli\stubs");sys.path.insert(1, ".micropy\pico_trial");'

which is just escaping the first letter of the path instead of having an actual backslash

Possible Solution

I would recommend changing to raw strings in the template files .\micropy\project\template\.pylintrc and .\tests\data\project_test\.pylintrc:

init-hook=r'import sys;sys.path.insert(1, ".micropy\micropy-cli\frozen");sys.path.insert(1, ".micropy\BradenM-micropy-stubs-4f5a52a\frozen");sys.path.insert(1, ".micropy\micropy-cli\stubs");sys.path.insert(1, ".micropy\pico_trial");'

Context (Environment)

  • OS: Windows 11
  • Micropy Version: 3.4.0 (latest version that installs under Python 3.10)
  • Python Version: 3.10.5
  • VSCode Version: 1.68.1

I've never contributed to open source or done any pull requests. It is a simple change and if you want to do it great. But because it is a simple change I wouldn't mind doing it for the sake of learning how to make a PR and getting involved in the open source community.

MilesStarr avatar Jul 07 '22 15:07 MilesStarr

@MilesStarr

Thanks for the report! I apologize it took me so long to get back to you.

I've never contributed to open source or done any pull requests. It is a simple change and if you want to do it great. But because it is a simple change I wouldn't mind doing it for the sake of learning how to make a PR and getting involved in the open source community.

Please do! I'd be happy to review and validate a PR for this.

Seems as if you have already found the related files, but here they are regardless: https://github.com/BradenM/micropy-cli/blob/7c716557ea6bba929ef61ed349e811ace249625c/micropy/project/template/.pylintrc#L3

https://github.com/BradenM/micropy-cli/blob/7c716557ea6bba929ef61ed349e811ace249625c/tests/data/project_test/.pylintrc#L3

BradenM avatar Aug 07 '22 07:08 BradenM