<commit_before>#!/bin/bash

set -o xtrace
set -o errexit

isort --check-only --diff .
black --diff --check .
flake8 --show-source .

# Indents are four spaces, binary ops can start a line, and indent switch cases
shfmt -i 4 -bn -ci -d .<commit_msg>Add support for formatting the code directly from lint.sh (#1140)<commit_after>#!/bin/bash

set -o errexit

help_and_exit() {
    echo "Usage: ./lint.sh [-f|--filter]"
    echo "  -f,  --filter         format code instead of just checking the format"
    exit 1
}

if [[ $# -gt 1 ]]; then
    help_and_exit
fi

FORMAT=0

while [[ $# -gt 0 ]]; do
    case $1 in
        -f | --format)
            FORMAT=1
            shift
            ;;
        *)
            help_and_exit
            ;;
    esac
done

set -o xtrace

if [[ $FORMAT == 1 ]]; then
    isort .
    black .
else
    isort --check-only --diff .
    black --check --diff .
fi

flake8 --show-source .

# Indents are four spaces, binary ops can start a line, and indent switch cases
shfmt -i 4 -bn -ci -d .
{'fraction_non_alphanumeric': 0.12807881773399016, 'fraction_numerical': 0.014778325123152709, 'mean_word_length': 1.853932584269663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2569225', 'n_tokens_mistral': 367, 'n_tokens_neox': 351, 'n_words': 126}