pylint as part of build ?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: pylint as part of build ?
What you could also do: there are tools for github which check the code style and can disable merging if the code style does not match.
That is the easiest solution to force everyone to write in the same style.
There seems to be also tools which will create new commits with linted code.
That is the easiest solution to force everyone to write in the same style.
There seems to be also tools which will create new commits with linted code.
Re: pylint as part of build ?
All these are great solutions and suggestions. In truth though I'm not that much concerned about _style_ (as in there must be a space ...), what I really would like to catch are bugs, or potential bugs. Basically what a compiler/linker does for C++, making sure that all the code that can be exercised is at least syntactically correct and free of typos - the latter being a vivid companion of mine.
AFAICT there are two options, lgtm or pylint. lgtm's integration into github's PR system is a brand new feature and currently being explored elsewhere or use pylint locally and run it as part of the unit tests.
TBH I do not advocate shipping pylint with FC - every developer on *nix can install it quite easily and the same is true for Windows. If the build for your PR fails you can install it if the logs from the build aren't conclusive, but that is not a requirement - or it shouldn't be.
AFAICT there are two options, lgtm or pylint. lgtm's integration into github's PR system is a brand new feature and currently being explored elsewhere or use pylint locally and run it as part of the unit tests.
TBH I do not advocate shipping pylint with FC - every developer on *nix can install it quite easily and the same is true for Windows. If the build for your PR fails you can install it if the logs from the build aren't conclusive, but that is not a requirement - or it shouldn't be.
Re: pylint as part of build ?
Has anyone actually tried to run it?
P.S. Please move this to Developers corner.
P.S. Please move this to Developers corner.
Re: pylint as part of build ?
Why was flake8 disabled?
https://github.com/FreeCAD/FreeCAD/pull/2637
https://github.com/FreeCAD/FreeCAD/pull/2637
Re: pylint as part of build ?
Apparently, flake8 doesn't verify signatures. It only verifies syntax and formatting. So if you import a module which doesn't exist or call a module without importing it, it won't complain. Pylint, OTOH will throw an error if you use a function or module incorrectly.saso wrote: ↑Thu Jul 04, 2019 8:00 am Is flake8 that we are already running basically not the same thing ? https://travis-ci.org/FreeCAD/FreeCAD/jobs/554080767
Still, flake8 is useful if you want to enforce snake_case naming. For that, you just need to install pep8-naming.
Re: pylint as part of build ?
Among other options are mypy and pyright. Those better support python stubs (pyi) which are required for C++ modules.
Re: pylint as part of build ?
Ok, here's a proof of concept to enforce snake_case in just one file (src/Mod/Draft/draftguitools/gui_snapper.py):
https://github.com/FreeCAD/FreeCAD/pull/3772
Next steps: provide snake_case aliases for all the internal C++ modules, add ignore pragmas for third-party modules, add deprecation warnings for camelCase versions, get everything to use snake_case.
https://github.com/FreeCAD/FreeCAD/pull/3772
Code: Select all
src/python-stubs/BimProject/__init__.pyi:1:6: N802 function name 'getHuman' should be lowercase
src/python-stubs/ArchSketchObject/__init__.py:3:6: N802 function name 'sortSketchWidth' should be lowercase
src/python-stubs/ArchSketchObject/__init__.py:3:30: N803 argument name 'edgeAlignList' should be lowercase
src/python-stubs/pivy/coin/__init__.pyi:1:6: N802 function name 'SoMaterial' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:7:6: N802 function name 'activateWorkbench' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:8:6: N802 function name 'addWorkbench' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:9:6: N802 function name 'removeWorkbench' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:10:6: N802 function name 'getWorkbench' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:11:6: N802 function name 'listWorkbenches' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:12:6: N802 function name 'activeWorkbench' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:13:6: N802 function name 'addResourcePath' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:14:6: N802 function name 'addLanguagePath' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:15:6: N802 function name 'addIconPath' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:16:6: N802 function name 'addIcon' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:17:6: N802 function name 'getIcon' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:18:6: N802 function name 'isIconCached' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:19:6: N802 function name 'getMainWindow' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:20:6: N802 function name 'updateGui' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:21:6: N802 function name 'updateLocale' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:22:6: N802 function name 'getLocale' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:23:6: N802 function name 'setLocale' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:24:6: N802 function name 'supportedLocales' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:25:6: N802 function name 'createDialog' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:26:6: N802 function name 'addCommand' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:26:28: N803 argument name 'commandObject' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:27:6: N802 function name 'runCommand' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:28:6: N802 function name 'SendMsgToActiveView' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:29:6: N802 function name 'sendMsgToFocusView' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:32:6: N802 function name 'hideObject' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:33:6: N802 function name 'showObject' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:37:6: N802 function name 'activeDocument' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:38:6: N802 function name 'activeView' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:39:6: N802 function name 'activateView' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:40:6: N802 function name 'editDocument' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:41:6: N802 function name 'getDocument' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:42:6: N802 function name 'doCommand' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:43:6: N802 function name 'doCommandGui' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:44:6: N802 function name 'addModule' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:45:6: N802 function name 'showDownloads' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:46:6: N802 function name 'showPreferences' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:47:6: N802 function name 'createViewer' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:48:6: N802 function name 'getMarkerIndex' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:49:6: N802 function name 'addDocumentObserver' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:50:6: N802 function name 'removeDocumentObserver' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:52:6: N802 function name 'loadFile' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:53:6: N802 function name 'coinRemoveAllChildren' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:56:10: N802 function name 'GetCommands' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:59:10: N802 function name 'GetResources' should be lowercase
src/python-stubs/FreeCADGui/__init__.pyi:64:2: N816 variable 'draftToolBar' in global scope should not be mixedCase
src/python-stubs/FreeCAD/__init__.pyi:6:2: N816 variable 'activeDraftCommand' in global scope should not be mixedCase
src/python-stubs/FreeCAD/__init__.pyi:9:6: N802 function name 'ParamGet' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:13:6: N802 function name 'saveParameter' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:17:6: N802 function name 'Version' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:19:6: N802 function name 'Vector' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:21:6: N802 function name 'Units' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:23:6: N802 function name 'getResourceDir' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:24:6: N802 function name 'getUserAppDataDir' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:27:10: N802 function name 'GetString' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:28:10: N802 function name 'GetInt' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:29:10: N802 function name 'GetFloat' should be lowercase
src/python-stubs/FreeCAD/__init__.pyi:30:10: N802 function name 'GetBool' should be lowercase
Re: pylint as part of build ?
mypy has a stricter option:
This enforces typings for pivy.coin and FreeCAD modules to be defined.
I couldn't find pyvi.coin type hints so I've created a request: https://github.com/coin3d/pivy/issues/71
If type hints can't be generated, then I suppose, they have to be provided manually.
Code: Select all
--check-untyped-defs
I couldn't find pyvi.coin type hints so I've created a request: https://github.com/coin3d/pivy/issues/71
If type hints can't be generated, then I suppose, they have to be provided manually.
Re: pylint as part of build ?
I'd vote for mypy. Type hinting would be nice to have.