Skip to content

add more precommits and CI caching for precommits

Avi Vajpeyi requested to merge avi.vajpeyi/bilby_pipe:add_more_precommits into master

New precommits:

Adds the following pre-commits:

  • check-merge-conflict
    • prevent committing files with merge conflicts
  • flake8
    • checks for flake8 errors
  • codespell
    • Runs a spellchecker
  • isort
    • sort imports alphabetically and separates import into sections

Example of spellchecker.
bilby_pipe/slurm.py:122: unneccessary  ==> unnecessary
docs/user-interface.txt:62: specifiy  ==> specify


tests/timeslide_test.py:148: dont  ==> don't

bilby_pipe/main.py:207: impemented  ==> implemented

bilby_pipe/data_files/generate_distance_lookups.py:27: hist  ==> heist, his

docs/installation.txt:135: recieve  ==> receive
docs/installation.txt:136: installtion  ==> installation
docs/installation.txt:168: everytime  ==> every time


bilby_pipe/create_injections.py:53: beforing  ==> before

docs/ini_file.txt:12: boolen  ==> boolean
bilby_pipe/utils.py:344: strng  ==> string


bilby_pipe/parser.py:123: internall  ==> internal, internally
docs/singularity.txt:10: prerequiste  ==> prerequisite
docs/singularity.txt:18: reproducable  ==> reproducible


bilby_pipe/data_generation.py:56: Defauts  ==> Defaults


docs/structure.txt:72: parallell  ==> parallel
bilby_pipe/input.py:348: veryify  ==> verify
bilby_pipe/input.py:352: enountered  ==> encountered

Example of isort.

Original:

from __future__ import division, print_function

import argparse
import sys
import json
import os

import pandas as pd
import numpy as np
import matplotlib

matplotlib.use("agg")  # noqa
import bilby

from .utils import (
    parse_args,
    logger,
    BilbyPipeError,
    check_directory_exists_and_if_not_mkdir,
)
from .input import Input

After isort reformats:

from __future__ import division, print_function

import argparse
import json
import os
import sys

import bilby
import matplotlib
import numpy as np
import pandas as pd

from .input import Input
from .utils import (BilbyPipeError, check_directory_exists_and_if_not_mkdir,
                    logger, parse_args)

Basically enforces the same import standards throughout a project.

CI file changes

precommits take a while to set up, hence I have set up caching of the pip files.

NOTE:

I have not run the pre-commits yet. When I do, a lot of the files will change. I would like to get other's opinions on this MR before I run the pre-commits.

Edited by Avi Vajpeyi

Merge request reports

Loading