Skip to content

Instantly share code, notes, and snippets.

@cdpath
Created October 25, 2021 03:51
Show Gist options
  • Save cdpath/37abaeb7a4dc41304d50501113b8c91a to your computer and use it in GitHub Desktop.
Save cdpath/37abaeb7a4dc41304d50501113b8c91a to your computer and use it in GitHub Desktop.
pre-commit and mypy
#!/bin/bash
set -euo pipefail
PRECOMMIT_CONFIG=".pre-commit-config.yaml"
MYPY_CONFIG="mypy.ini"
echo "installing pre-commit"
pip install pre-commit
echo "write pre-commit config to " $PRECOMMIT_CONFIG
cat << EOF > $PRECOMMIT_CONFIG
repos:
- repo: https://github.com/ambv/black
rev: 21.6b0
hooks:
- id: black
language_version: python3.8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/timothycrosley/isort
rev: 5.9.1
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.910'
hooks:
- id: mypy
additional_dependencies:
- 'pydantic'
- 'sqlalchemy-stubs'
- 'types-requests'
- 'types-redis'
EOF
echo "install pre-commit plugins"
pre-commit install
echo "write mypy config"
cat << EOF > $MYPY_CONFIG
[mypy]
plugins = pydantic.mypy, sqlmypy
ignore_missing_imports = True
disallow_untyped_defs = True
[mypy-tests.*]
ignore_errors = True
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment