mihirkatare / DeepMEM

Deep Learning Implementations for Sustainable Matrix Element Method Calculations [ IRIS-HEP Fellowship ]
Apache License 2.0
2 stars 0 forks source link

chore: Add linting and formatting pre-commit hooks #11

Closed matthewfeickert closed 2 years ago

matthewfeickert commented 3 years ago

This PR adds linting and formatting pre-commit hooks discussed in https://github.com/mihirkatare/DeepMEM/issues/1#issuecomment-902276528 to make code style self consistent and offload code health improvements to automatic checks. Also has a nice advantage of minimizing diffs from code changes in the future. c.f. the Scikit-HEP developer guide for even more information. :+1:

@mihirkatare This PR will look far more aggressive then it really is as it is just applying lots of small code formatting with pyupgrade, Black, and isort. However, there is zero change to the code functionality — it is all just linting and formatting.

That being said, I'd encourage you to give it a look over and I'm more than happy to discuss any and all changes. :) As there is a lot of linting here too it can be configured a bit to some degree if you find any changes too drastic (though Black is pretty aggressive by nature, though it views this as a feature).

Suggested squash and merge commit message:

* Add pyupgrade, isort, flake8, black pre-commit hooks and add them as dev-requirements
   - The addition to dev-requirements.txt is purely so they can be run individually as well as together with `pre-commit run --all-files`
   - Add Black code style badge to README
* Add check-json and check-toml checks to pre-commit/pre-commit-hooks pre-commit hook
* Add pyproject.toml and .flake8 for configuration of Black and flake8
* Apply pre-commit hooks to apply code formatting and remove unused imports

Co-authored-by: Mihir Katare <69146650+mihirkatare@users.noreply.github.com>
matthewfeickert commented 3 years ago

Okay this is now rebased off of main and ready for review. :+1: