Open steffencruz opened 1 year ago
Pre-push hooks are another option
RE: 4.
function remove_trailing_whitespace() {
if [ -d "$1" ]; then
find "$1" -type f -name "*.py" -exec sed -i 's/[ \t]*$//' {} \;
echo "Trailing whitespace removed from all Python files in the directory: $1"
else
echo "Directory not found: $1"
fi
}
Add to ~/.bashrc
Usage:
remove_trailing_whitespace /path/to/your/project
Cool solution! There's actually a simple way to do this within the pre-commit hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace # <--------------------THIS BAD BOI
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [-l 120]
types: [python]
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: [--count, --select=E9, --select=F63, --select=F7, --select=F82, --show-source, --statistics]
types: [python]
Because you know you should