Closed theUpsider closed 1 year ago
Also made a git hook for pre-commit:
#!/bin/sh
# This is a git pre-commit hook to run isort, black, and flake8 on staged files
# Set venv_dir variable based on OS
case "$OSTYPE" in
msys*) venv_dir="./venv_hooks/Scripts" ;;
*) venv_dir="./venv_hooks/bin" ;;
esac
# Install virtualenv if not already installed and create virtualenv if not already created
if [ ! -d "./venv_hooks" ]; then
echo "Creating virtualenv"
python -m venv venv_hooks
$venv_dir/python -m pip install -r requirements.txt
fi
echo "Activating virtualenv"
source $venv_dir/activate
# Get list of staged python files
files="$(git diff --name-only --cached | grep '.*\.py$' | paste -sd ' ' -)"
if [ "$files" == "" ]; then
echo "No files to reformat, skipping"
exit 0
fi
# isort
echo "Running isort on staged files"
isort $files --settings-file=./pyproject.toml
if [ $? -ne 0 ]; then
echo "isort failed, please run isort on your code"
exit 1
fi
# black
# check if black config exists
if [ -f ./pyproject.toml ]; then
echo "Found black config"
else
echo "No black config found, skipping"
exit 0
fi
echo "Running black on staged files"
black $files --config=pyproject.toml
if [ $? -ne 0 ]; then
echo "Black check failed, please run black on your code"
exit 1
fi
# flake8
echo "Running flake8 on staged files"
flake8 $files
if [ $? -ne 0 ]; then
echo "flake8 failed, please run flake8 on your code"
exit 1
fi
# # Add files to commit
# echo "Adding files to commit"
# git add $files
This would be placed in .git\hooks\pre-commit
to work.
Kudos, SonarCloud Quality Gate passed!
Describe the feature to be developed
This feature aims to enhance project configuration and setup, streamline development, improve code quality checks, and simplify setup for developers.
Describe the Impact on the System
The changes primarily affect the project's setup and configuration files, as well as some scripts related to database setup and cleanup. The most significant impact will be on the following areas:
.flaskenv
and a new.flaskenv_template
).github/workflows/build.yaml
)requirements.txt
)db_setup.py
anddb_clean_up.py
)pyproject.toml
and deletedtox.ini
)validate_script.py
)Definition of Done
Before this pull request can be considered complete, the following tasks need to be accomplished:
.flaskenv_template
file has been reviewed and confirmed to provide correct setup guidance.requirements.txt
file do not conflict with existing dependencies.db_clean_up.py
anddb_setup.py
files work as expected.pyproject.toml
file correctly handles project management tasks.