FEM Python coding standard

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
bernd
Posts: 8340
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Python coding standard

Postby bernd » Fri Feb 10, 2017 7:04 am

cool, I need to get in all this documentation possibilities. In the regard off your commits. Since they are all FEM snd they all do the same, I would squash them into one commit.
bernd
User avatar
bernd
Posts: 8340
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Python coding standard

Postby bernd » Fri Feb 10, 2017 7:04 am

cool, I need to get in all this documentation possibilities. In the regard off your commits. Since they are all FEM snd they all do the same, I would squash them into one commit.
bernd

PS: I could squash them and add it to my FEM dev branch I'm gone make a PullRequest soon hopefully. Means less work for yorik or werner
User avatar
Kunda1
Posts: 5522
Joined: Thu Jan 05, 2017 9:03 pm

Re: Python coding standard

Postby Kunda1 » Fri Feb 10, 2017 11:09 am

bernd wrote:cool, I need to get in all this documentation possibilities. In the regard off your commits. Since they are all FEM snd they all do the same, I would squash them into one commit.
bernd

PS: I could squash them and add it to my FEM dev branch I'm gone make a PullRequest soon hopefully. Means less work for yorik or werner
Yea.. that would be great :) Thanks!
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
bernd
Posts: 8340
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Python coding standard

Postby bernd » Fri Feb 10, 2017 4:25 pm

Kunda1 wrote:
bernd wrote:cool, I need to get in all this documentation possibilities. In the regard off your commits. Since they are all FEM snd they all do the same, I would squash them into one commit.
bernd

PS: I could squash them and add it to my FEM dev branch I'm gone make a PullRequest soon hopefully. Means less work for yorik or werner
Yea.. that would be great :) Thanks!
https://github.com/berndhahnebach/FreeC ... its/femdev
https://github.com/berndhahnebach/FreeC ... 1ba697f475
User avatar
bernd
Posts: 8340
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM Python coding standard

Postby bernd » Thu Sep 05, 2019 10:14 pm

User avatar
Kunda1
Posts: 5522
Joined: Thu Jan 05, 2017 9:03 pm

Re: FEM Python coding standard

Postby Kunda1 » Thu Sep 05, 2019 10:20 pm

Maybe adding codespell in to the workflow ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
bernd
Posts: 8340
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM Python coding standard

Postby bernd » Fri Sep 06, 2019 5:54 am

Kunda1 wrote:
Thu Sep 05, 2019 10:20 pm
Maybe adding codespell in to the workflow ?
https://github.com/codespell-project/codespell
User avatar
bernd
Posts: 8340
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM Python coding standard

Postby bernd » Fri Sep 06, 2019 6:00 am

User avatar
bernd
Posts: 8340
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM Python coding standard

Postby bernd » Fri Sep 06, 2019 6:02 am

why do we add these huge list of words to codespell ?

Code: Select all

aci,aline,alledges,als,ang,beginn,behaviour,bloaded,calculater,cancelled,cancelling,cas,cascade,centimetre,childs,colour,colours,currenty,doubleclick,dum,eiter,elemente,feld,freez,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oder,ot,pres,programm,que,recurrance,rougly,seperator,serie,sinc,strack,substraction,te,thist,thru,tread,vertexes,uint,unter,whitespaces -S *.ts,*.po src/Mod/Fem
User avatar
Kunda1
Posts: 5522
Joined: Thu Jan 05, 2017 9:03 pm

Re: FEM Python coding standard

Postby Kunda1 » Fri Sep 06, 2019 11:48 am

bernd wrote:
Fri Sep 06, 2019 6:02 am
why do we add these huge list of words to codespell ?
Those are ignored words that if not added to that list would prompt you to correct them. There are even scenarios when legit typos are added, say a developer in a project wrote a piece of code with functions that have misspellings in them and now because of backward compatibility they don't want to break the API or issue an API modification. The easier scenarios is just to agree to ignore the typo.

Code: Select all

 -L WORDS, --ignore-words-list WORDS
                        Comma separated list of words to be ignored by
                        codespell. Words are case sensitive based on how they
                        are written in the dictionary file
BTW, The recommended flags to use when running codespell.

codespell -i 3 -w -S <list of directories to ignore> -L <list of words to ignore>
  • -I flag means 'interactive' and codespell will prompt you everytime it reaches a typo. Would you like to fix it (y/n)? and if there are multiple choice options - which one would you prefer to chose?
    The number 3 indicates the level of interactivity:

    Code: Select all

      -i INTERACTIVE, --interactive INTERACTIVE
                            Set interactive mode when writing changes. 0: no
                            interactivity. 1: ask for confirmation. 2 ask user to
                            choose one fix when more than one is available. 3:
                            both 1 and 2
    
  • -w flag indicates to go ahead and write the change you're requesting to make (without this is like running a 'Dry Run' of codespell which shows you what it would fix but doesn't actually make changes to the disk)
  • -S flag takes a comma separated list of directories for ex. ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller
    Important notes; do not end any of they directory paths with a slash because codespell will ignore it; you can use wild cards (at least asterisks), only a comma separates one directory from another (a whitespace after a comma will not be recognized)
  • -L flag takes a comma separated list of ignored words
You can also target certain directories by appending them to the command i.e.
codespell <variouscodespell flags> <1st directory to search> <2nd directory to search> <nth directory to search>
codespell -q 2./src/Mod/Fem ./src/Mod/Material
note: -q <number> suppresses codespell output in specific cases (I like to use level 2 which suppresses binary files that codespell will say it has encountered)

Edit:
The most up to date codespell list of flag for FreeCAD is:

Code: Select all

codespell -q 2 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,ba,beginn,behaviour,bloaded,byteorder,calculater,cancelled,cancelling,cas,cascade,centimetre,childs,colour,colours,commen,currenty,dof,doubleclick,dum,eiter,elemente,feld,freez,hist,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,ist,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oder,ot,pard,pres,programm,que,recurrance,rougly,seperator,serie,sinc,strack,substraction,te,thist,thru,tread,uint,unter,vertexes,wallthickness,whitespaces -S ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller,./src/Doc/FreeCAD.uml
Edit2:
Make sure you using the development version of codespell which has it's dictionary updated fairly often. If you don't want to run pip and install the development version you can use

Code: Select all

wget https://raw.githubusercontent.com/codespell-project/codespell/master/codespell_lib/data/dictionary.txt
and then use the -D flag on the dictionary,txt to run codespell against i.e
codespell -D <path/to/dictionary.txt>
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features