Skip to content

Use Black to format code

Chandan Singh requested to merge chandan/black into master

See https://mail.gnome.org/archives/buildstream-list/2019-November/msg00001.html and it's follow-ups for some background.

Changes proposed in this merge request:

  • Add configuration to run Black

    Introduce two new tox environments - format and format-check. The format environment will reformat the code using black whereas the format-check envrionment will simply print the diff without modifying any files.

    Configure Black to use the same line lengths that we use currently, i.e. 119.

  • .pylintrc: Disable formatting messages

    Since we use Black to format our code, disable code-formatting messages from Pylint as they are already taken care of by Black. This ensures that we don't get double warnings for the same problem, and that Pylint and Black don't fight with each other over style.

  • Remove pycodestyle

    Now that PEP8 style is enforced by Black, we don't need another tool checking the same. So, remove all configuration related to pycodestyle.

  • .gitlab-ci.yml: Check code formatting as part of CI

    As part of the lint CI job, also check code formatting.

  • Reformat code using Black

    As discussed over the mailing list, reformat code using Black. This is a one-off change to reformat all our codebase. Moving forward, we shouldn't expect such blanket reformats. Rather, we expect each change to already comply with the Black formatting style.

  • doc/source/hacking: Remove pycodestyle, add Black

    Now that code formatting is managed by Black, and we don't need to run pycodestyle separately, remove corresponding mentions from hacking documentation.

    Add documentation on how to run Black.

    Move out linting and formatting into a separate section for better readability.

Edited by Chandan Singh

Merge request reports

Loading