jazzband / tablib

Python Module for Tabular Datasets in XLS, CSV, JSON, YAML, &c.
https://tablib.readthedocs.io/
MIT License
4.61k stars 593 forks source link

Update testing: add docs + lint jobs; use pre-commit for linting #426

Closed hugovk closed 4 years ago

hugovk commented 4 years ago

pre-commit

pre-commit can be used locally to check files when committing. If problems are found, it stops the commit with an error message. Some tools also fix the problems they find.

Fail fast, fail early.

pre-commit is not for everyone, and it's not mandatory to run it locally. I didn't used to be keen, but now I find it really helpful. It's important it doesn't take too long to run.

Even if you don't run it locally, it's handy for grouping together many linters, and running on the CI.

Here are the main commands for local use.

# Do this just once to init a repo:
pre-commit install

# The first run can take a bit longer to set up, after that it's quick

# Then commit like normal, it’ll run the checks on only the staged files:
git commit -m "something"

# If you want to skip the pre-commit checks:
git commit -m "something" -n

# If you want to run on all files:
pre-commit run all-files

# Once in a while, check for new versions of your lint tools:
pre-commit autoupdate  # and then commit the updated config file

# Stop using it locally:
pre-commit uninstall

I added some extra handy linters, such as check-yaml, which is really handy to find syntax errors in, say, .travis.yml before pushing and trying to find out why nothing was built.

We can also add Black and Flake8 here, when we're ready.

rst-backticks found some problems, which I've fixed, and pyupgrade made a couple of upgrades, which are included.