Add auto formatter
As I learned in #213 , h3 currently uses flake8 for linting, requiring a max line length of 88 chars, but does not use an auto-formatting solution. This means that manual editing is required to format code in a way that passes flake8.
This PR adds two autoformatters: black and isort. black is likely the most commonly used Python formatter at this time and is used by many popular projects. black autoformats code while isort sorts imports deterministically. This PR uses pre-commit as a method to easily run all linting together, pinned to specific tag versions. And it can run automatically on each git commit if you run pre-commit install.
Formatting is bound to be subjective, so I'm happy to hear criticism or changes desired, but I personally would be in favor of any solution that avoids the need for manual editing of code to meet formatting requirements.
Codecov Report
Merging #215 (d894b2d) into master (409a6e5) will not change coverage. The diff coverage is
100.00%.
:exclamation: Current head d894b2d differs from pull request most recent head 91f5725. Consider uploading reports for the commit 91f5725 to get more accurate results
@@ Coverage Diff @@
## master #215 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 213 211 -2
=========================================
- Hits 213 211 -2
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/h3/api/memview_int.py | 100.00% <ø> (ø) |
|
| src/h3/__init__.py | 100.00% <100.00%> (ø) |
|
| src/h3/_cy/__init__.py | 100.00% <100.00%> (ø) |
|
| src/h3/api/__init__.py | 100.00% <100.00%> (ø) |
|
| src/h3/api/_api_template.py | 100.00% <100.00%> (ø) |
|
| src/h3/api/basic_int.py | 100.00% <100.00%> (ø) |
|
| src/h3/api/basic_str.py | 100.00% <100.00%> (ø) |
|
| src/h3/api/numpy_int.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 409a6e5...91f5725. Read the comment docs.