Errors on startup

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
reox
Posts: 929
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Errors on startup

Post by reox »

PMac wrote: Tue Apr 07, 2020 4:54 pm
reox wrote: Sun Apr 05, 2020 11:42 am There are much more of the SyntaxWarnings.
But I have not found a good way to find them statically in the code. Does anyone know a method for that? I tried it with pylint but it looks like you can not find them that way.
With a static code analyzer it would probably be very easy to find all those warnings and resolve them.
Hi Reox, Not sure if your post was meant for this thread. Way beyond my initial reported fault as I'm not compiling locally. Maybe someone else could help?
Yes it was. I was mentioning the SyntaxWarnings which were introduced in python3.8 - which was the thread opener's initial question.
The idea would be to get rid of all these SyntaxWarnings at once, however therefore they must be found. And I'm not sure if there are static code analyzers which are able to do this - so far, I found none. Maybe these SyntaxWarnings are just too new and the tools havn't adopted yet.

edit: no wait, you can get them via pylint. But they are just recommendations:

Code: Select all

find . -name \*.py -exec pylint --disable=all --enable=R0123 --score=no {} \; | tee -a pylint_R0123.txt
************* Module feminout.writeFenicsXDMF
src/Mod/Fem/feminout/writeFenicsXDMF.py:320:7: R0123: Comparison to literal (literal-comparison)
************* Module feminout.importFenicsMesh
src/Mod/Fem/feminout/importFenicsMesh.py:189:15: R0123: Comparison to literal (literal-comparison)
************* Module femexamples.manager
src/Mod/Fem/femexamples/manager.py:70:7: R0123: Comparison to literal (literal-comparison)
src/Mod/Fem/femexamples/manager.py:81:16: R0123: Comparison to literal (literal-comparison)
So it looks like the last files were this is happening are the three above.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Errors on startup

Post by vocx »

reox wrote: Sun Apr 05, 2020 11:42 am ...
With a static code analyzer it would probably be very easy to find all those warnings and resolve them.
I suggest using flake8. It includes pylint and pycodestyle.

Code: Select all

find src/Mod -name '*.py' ! -name InitGui.py -exec flake8 --ignore=E226,E266,W503 --max-line-length=100 '{}' '+'
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
duncandoo
Posts: 5
Joined: Mon Jan 27, 2020 7:22 pm

Re: Errors on startup

Post by duncandoo »

chrisb wrote: Tue Jan 28, 2020 6:45 pm Just installed a new 0.19. On startup I get the following error message in report view:

Code: Select all

/Users/cb/Desktop/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/numpy/ma/core.py:4466: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.shape is ():
/Users/cb/Desktop/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/mpmath/ctx_mp_python.py:892: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if other is 0:
/Users/cb/Desktop/FreeCAD.app/Contents/Resources/lib/python3.8/site-packages/mpmath/ctx_mp_python.py:986: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if other is 0:
The previous version used Python3.8 as well and did not show these errors.

OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19405 (Git)
Build type: Release
Branch: master
Hash: d2b943e8b7d8fe2673a4e20671b6cb0f8180fdbd
Python version: 3.8.1
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
I've got the same issue with 0.19 build 22164. Changing the two lines as suggested gets rid of the message. I tried to follow it back to original mpmath, https://github.com/fredrik-johansson/mp ... _python.py. These lines were fixed on 20th March 2019 in commit 4490fb5. The question that I can't figure out is where FreeCAD is getting it's version of this module from? Can it be change to use the current version of mpmath?
Post Reply