Skip to content

Instantly share code, notes, and snippets.

@tdhopper
Last active July 21, 2022 12:52
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdhopper/ae09efe739247029e096e6dbdd891544 to your computer and use it in GitHub Desktop.
Save tdhopper/ae09efe739247029e096e6dbdd891544 to your computer and use it in GitHub Desktop.
Configuration files to enable validating python code with flake8, mypy, isort, and black using pre-commit hooks (via https://pre-commit.com/). Also an .editorconfig file for standardization across editors.
# http://editorconfig.org/#file-format-details
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab
[flake8]
max-line-length = 88
select =
E # pep8 errors
F # pyflakes errors
W # pep8 warnings
B # flake8-bugbear warnings
ignore =
E501 # "Line lengths are recommended to be no greater than 79 characters"
E203 # "Whitespace before ':'": conflicts with black
W503 # "line break before binary operator": conflicts with black
exclude =
.git
.vscode
.pytest_cache
.bamboo
.mypy_cache
.venv
.env
.direnv
per-file-ignores =
__init__.py:F401
exclude: docs
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: "3.8.3"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- repo: https://github.com/psf/black
rev: "20.8b1"
hooks:
- id: black
args:
- --check
- repo: https://github.com/PyCQA/isort
rev: '5.5.3' # Use the revision sha / tag you want to point at
hooks:
- id: isort
args:
- --check
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.910'
hooks:
- id: mypy
args:
- --ignore-missing-imports
- --follow-imports=silent
- --install-types
- --non-interactive
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.26.1
hooks:
- id: yamllint
args: ["--config-file", ".yamllint.yaml"]
---
extends: relaxed
rules:
line-length: disable
[tool.isort]
line_length = 88
profile = "black"
skip = ["./.venv", "./direnv", ".env"]
[tool.black]
exclude = '''
(
/(
\.vscode
| \.git
| \.pytest_cache
| \.mypy_cache
| \.venv
| \.env
| \.direnv
)/
)
'''
include = '\.pyi?$'
line-length = 88
[tool.pytest.ini_options]
testpaths = ["tests"]
[tool.mypy]
files = [
"src/**/*.py",
"tests/**/*.py",
]
follow_imports = "silent"
ignore_missing_imports = true
scripts_are_modules = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment