Skip to content

Commit

Permalink
Create pre-commit.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasvinaya authored Apr 10, 2024
1 parent e2f7f6f commit 5e62bdf
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Check if file argument was provided
if [ $# -eq 0 ]; then
echo "Error: no file provided"
exit 1
fi

# Get filename from first argument
file=$1

# Format file with yapf
echo "Formatting $file with yapf"
python -m yapf -i "$file"

# Type check qtsit package
echo "Type checking deepchem package with mypy"
python -m mypy -p qtsit

# Lint file with flake8 and show count
echo "Linting $file with flake8"
python -m flake8 "$file" --count

# Check if filename contains "test"
if [[ $file != *"test"* ]]; then
# Test file with doctest
echo "Testing $file with doctest"
python -m doctest "$file"
else
echo "Skipping doctest for test file $file"
echo "running pytest on $file"
python -m pytest "$file"
fi
~

0 comments on commit 5e62bdf

Please sign in to comment.