Skip to content

Add formatting pre-commit hooks #1070

Closed
@maichmueller

Description

@maichmueller

From what I can tell the repo does not have consistent formatting on the c++ side nor on the Python side due to there not being a shared formatting setup in the repo (unsure about Julia/Rust).
Yet, this could be as easy as setting up a .clang-format and black config and pre-commit hooks! The pre-commits may also be extended for automatic linting (flake8, mypy) and more.

Advantages:

  • standardized code!
  • no need for manual linting, formatting, or other requests from PR contributors as every commit is automatically checked and corrected (if e.g. just formatting)
  • clear formatting guidelines for every contributor and no accidental large diffs in PRs (had this problem myself)
  • no extra dependency on the user side

Disadvantages:

  • a one-off behemoth diff that formats the entire codebase
  • developers will need to install the pre-commit package and run pre-commit install once inside the repo (could also be automated in the install script)

If this is interesting for the project, then I would suggest starting with formatters in the pre-commit and adding linters later. I could provide a PR to try this.
What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions