libAtoms / testing-framework

11 stars 7 forks source link

Formatting python code #12

Open LarsSchaaf opened 3 years ago

LarsSchaaf commented 3 years ago

I was wondering if we could decide on a formatter to format the code according to one convention. I had talked to @stenczelt about this before and he also uses black, which might be a good suggestion as its a widely used formatter.

Why add a formatter

  1. Easier to merge pull requests: as all conventions are the same, it is easier to merge pull requests as the only differences are in code content rather than which quotation marks were used ect.
  2. Ease of reading code
  3. Simple to use
  4. Now might be a good time to improve formatting, as there are significant changes with the file structure already.

How to use?

pip install black
# or 
conda install -c conda-forge black

To use black simpy do: black file_to_format.py or use black * to format whole direcotries, or whole repository. The easiest way to use black is by integrating it into your favourite editor and formatting upon save: for VS Code, for Jupyter Noteooks.