Skip to content

Conversation

@the-david-oy
Copy link
Contributor

This pull request adds pre-commit hooks. It also includes running the pre-commit hooks on these files, plus making fixes based on them (e.g. making sure all .py and .sh executables are set to be executable and have shebangs, spelling corrections, etc.).

This pull request adds pre-commit hooks to run the following:

  • Black for formatting Python
  • Flake8 for linting Python for conformance to PEP8, PyFlakes, and circular complexity (max-line-length set to match Black's 88 default/recommended character limit; this and other settings from Black's documentation here to avoid enforcement of limit when unnecessary).
  • isort for deterministically sorting and organizing Python imports
  • Clang for formatting C++, C, Java, TextProto, Proto, and CUDA
  • Codespell for finding common spelling mistakes

In addition, this adds these native pre-commit hooks, details here:

  • check-case-conflict
  • check-executables-have-shebangs
  • check-merge-conflict
  • check-json
  • check-toml
  • check-yaml
  • check-shebang-scripts-are-executable
  • end-of-file-fixer
  • mixed-line-ending
  • requirements-txt-fixer
  • trailing-whitespace

To run these locally, you can go into the repo and run pip install pre-commit and pre-commit install. After that has been done once, you just need to run pre-commit run --all-files any time you want to apply them. Once installed, it should run automatically on commit for files included in a commit. To correct spelling errors found by codespell when possible, you can install codespell (pip install codespell and potentially pip install --upgrade codespell to use the toml file in the directory) and call codespell -w <path>.

This pull request also adds a GitHub action so that these are run for every pull request and push to main. The core changes are in pre-commit.yml, pre-commit-config.yaml, and pyproject.toml. The rest of the changes are the effect of applying the action to the current repo.

@the-david-oy the-david-oy marked this pull request as ready for review July 11, 2023 02:37
@the-david-oy the-david-oy requested review from krishung5 and kthui July 11, 2023 03:04
@the-david-oy the-david-oy merged commit 304c2e8 into main Jul 11, 2023
@the-david-oy the-david-oy deleted the dyas-precommit branch July 11, 2023 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants