File size: 1,048 Bytes
c26f879 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #!/bin/bash
# Script to run linters the same way as in the GitLab CI pipeline
# Default mode is check only
FIX_MODE=false
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--fix) FIX_MODE=true ;;
*) echo "Unknown parameter: $1"; exit 1 ;;
esac
shift
done
# Install required packages if not already installed
echo "Checking for required linting tools..."
pip install black ruff
# Set the mode message
if [ "$FIX_MODE" = true ]; then
echo "Running in FIX mode - will automatically correct issues"
else
echo "Running in CHECK mode - will only report issues"
fi
# Run Ruff lint checks
echo "Running Ruff linting checks..."
if [ "$FIX_MODE" = true ]; then
python -m ruff check --fix .
else
python -m ruff check .
fi
# Run Ruff import sorting and Black
echo "Running style checks..."
if [ "$FIX_MODE" = true ]; then
python -m ruff check --select I --fix .
python -m black .
else
python -m ruff check --select I .
python -m black --check .
fi
echo "Linting completed!" |