VS Code Pymar microython

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
programablearg
Posts: 1
Joined: Wed Jan 12, 2022 11:55 pm

VS Code Pymar microython

Post by programablearg » Thu Jan 13, 2022 12:01 am

Hello everyone, I am taking up an old project that I have with an esp32. I want to do it with micropython, I configured everything to work with vscode, but I have a detail to solve.


It gives me a warning that I would like to solve, it does not affect the operation since it works perfectly.

from machine import Pin

A warning underline appears below the word machine. With the following text

Import "machine" could not be resolved

Can this be solved?

Thanks a lot

Uthayamurthy
Posts: 4
Joined: Sun Dec 19, 2021 2:45 pm

Re: VS Code Pymar microython

Post by Uthayamurthy » Thu Jan 13, 2022 3:03 pm

Hi programablearg. May I know how you have configured VS Code for micropython (i.e plugins or anything else.) ?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: VS Code Pymar microython

Post by Roberthh » Thu Jan 13, 2022 3:11 pm

You can ignore the warning. The standard Python plugin for VS-Code knows CPython, but it does not know MicroPython.

Uthayamurthy
Posts: 4
Joined: Sun Dec 19, 2021 2:45 pm

Re: VS Code Pymar microython

Post by Uthayamurthy » Thu Jan 13, 2022 3:58 pm

Yes Roberthh, you are right. That warning should be harmless. But I think there are some special plugins for VS Code to aid micropython development (eg - Micropython IDE, Pymakr). I think there should not be any warnings if such extensions are used, not exactly sure though, since I haven't tried these extensions.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: VS Code Pymar microython

Post by Roberthh » Thu Jan 13, 2022 4:03 pm

The Pymakr IDE is for the Pycom variant of MicroPython. And pymakr is notoriously failing every month with a new VSCode release.

User avatar
josverl
Posts: 15
Joined: Fri Nov 24, 2017 4:22 pm

Re: VS Code Pymar microython

Post by josverl » Thu Jan 27, 2022 9:15 am

in order to get better language support for MicroPython in VScode, pylint, pycharm and others you can take a look at https://micropython-stubs.readthedocs.io/

Its not perfect, but I try to make it not wrong while still helping to write code simpler and with fewer errors.
allows you to select a specific version, port and board to check against, or use a simpler generic fallback.

Currently the initial setup requires you to clone the entire repo, working on making the installation of the type-stubs simpler by using type-packages.

User avatar
josverl
Posts: 15
Joined: Fri Nov 24, 2017 4:22 pm

Re: VS Code Pymar microython

Post by josverl » Thu Jan 27, 2022 9:20 am

@Robert, pymakr works fine with any port of micropython that exposes a serialport that has a driver on you Host platform.
and indeed , the Javascript serialport OSS library that is used has it's challenges in keeping up with the electron versions .
In the recent iterations Pycom has been much more responsive in fixing these issues though

jim
Posts: 20
Joined: Tue Feb 23, 2021 10:22 pm

Re: VS Code Pymar microython

Post by jim » Tue Feb 08, 2022 11:07 pm

Language and lint checking can be disabled for individual lines by appending "type: ignore" as a comment. For example:

Code: Select all

import machine              # type: ignore
This will also cause any machine.[*] call to not trigger a warning.

Checking for an entire file can be disable by putting the same as a line comment at the top of the file:

Code: Select all

# type: ignore

mzm
Posts: 3
Joined: Fri Dec 18, 2020 3:07 pm

Re: VS Code Pymar microython

Post by mzm » Sun Dec 18, 2022 9:24 pm

With VS Code 1.74.1 and Ubuntu 22.04 only pymakr-preview 2.25.2 works.

Jackli
Posts: 80
Joined: Thu Apr 29, 2021 9:11 am

Re: VS Code Pymar microython

Post by Jackli » Thu May 25, 2023 7:37 am

Do you need to import the official machine, otherwise it may result in incompatible versions. :)

Post Reply