Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Seeing Python Syntax Errors in VS Code

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
KennethOfLeesburg
9545 Views, 4 Replies

Seeing Python Syntax Errors in VS Code

In the new VS Code debugger (which is mostly working well for me (and which I like much better than the old IDE)), I can't figure out where syntax errors are reported.

 

I'm more of a C++ guy and make a lot of little syntax errors when writing Python code.  Every time I make such an error the following happens:

  • I click the DEBUG button in the scrip window.
  • VS Code launches and opens the correct file.
  • I click F5 in the VS window.
  • VS "thinks" for anywhere from a few milliseconds to several seconds.

And then nothing.  It doesn't start the debugger.  It doesn't report an error message (or any problems).  Just nothing.

 

Then I stare at the code until I see the syntax error, fix it, repeat the same process and the debugger starts and steps to "main".  As my code size grows this is becoming unworkable; staring works better on a short test program than on a longer more product oriented program. 

 

It must be generating an error message like "unexpected semicolon on line 31", but I don't know where to look.

4 REPLIES 4
Message 2 of 5

Hi Mr. KennethOfLeesburg

 

Please consider checking (using outside to F360 docs) linting processes in Python environment.

In VSCode the process can be activated from <View><Command Palette...>. Type at the prompt <Lint...>

and you will see available options.

 

Regards

MichaelT

MichaelT
Tags (1)
Message 3 of 5

Hi @KennethOfLeesburg ,

You can follow method suggested by @MichaelT_123 .
Same thing you can achieve by  setting flag "python.linting.pylintEnabled" to true in settings.json file present in the .vscode directory as shown in screenshot"Enableflag.png".Enableflag.PNG

 

And if you have not installed pylint, vscode will ask you to install the same with a poup message.
Once setup is done, pylint will start showing you the warnings in the 'PROBLEMS' window of vscode after you save the changes as shown in example "DemoWarning.png".

DemoWarning.PNG

For further your reference -
Currently pylint is also showing warning for import of adsk.core,adsk.fusion & adsk.cam modules even-though we have added the extra def paths to the vscode (Still script will run successfully). That's why we are setting "python.linting.pylintEnabled" flag to "false" before opening sripts to avoid confusion. We are working on addressing this issue.
FalseNegativeWarning.png


Nilesh Mohite
LinkedIn

If my answer helped you, please use  ACCEPT SOLUTION .
Also be generous with Likes!  Thank you and enjoy!

Tags (2)
Message 4 of 5

VSCode only supports one directory in the PythonPath so it raises exceptions on import adsk.core.
Asked my son about it (he's a computer genius, not like his dad).

So it seems, all that is needed is to add a comment after the import to tell Pylint what to do.

with this sort of line, the pylintEnabled can be set to true:

 

import adsk.core, adsk.fusion # pylint: disable=import-error

Message 5 of 5

@franck.gressier ,

Thanks for the reply. 

We will surely look in to it. 
Special thanks to your son for his help.

 


Nilesh Mohite
LinkedIn

If my answer helped you, please use  ACCEPT SOLUTION .
Also be generous with Likes!  Thank you and enjoy!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report