diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..e533d06 --- /dev/null +++ b/.flake8 @@ -0,0 +1,7 @@ +[flake8] +# Based directly on Black's recommendations: +# https://black.readthedocs.io/en/stable/the_black_code_style.html#line-length +max-line-length = 81 +select = A,C,E,F,W,B,B950 +#B305 doesn't like `.next()` that is a key Tree method. +ignore = E203, E501, W503, B305 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c159c99..7da3596 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,10 +3,13 @@ name: Tests on: pull_request: push: - branches: [main] + branches: [main, test] merge_group: jobs: + pre-commit: + name: Lint + uses: tskit-dev/.github/.github/workflows/lint.yml@v1 test: name: Python runs-on: ${{ matrix.os }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..8384b3c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-merge-conflict + - id: debug-statements + - id: mixed-line-ending + - id: check-case-conflict + - id: check-yaml + - repo: https://github.com/asottile/reorder_python_imports + rev: v3.15.0 + hooks: + - id: reorder-python-imports + - repo: https://github.com/asottile/pyupgrade + rev: v3.20.0 + hooks: + - id: pyupgrade + args: [--py3-plus, --py38-plus] + - repo: https://github.com/psf/black + rev: 25.1.0 + hooks: + - id: black + language_version: python3 + - repo: https://github.com/pycqa/flake8 + rev: 7.3.0 + hooks: + - id: flake8 + args: [--config=.flake8] + additional_dependencies: ["flake8-bugbear==23.9.16", "flake8-builtins==2.1.0"] + - repo: https://github.com/asottile/blacken-docs + rev: 1.20.0 + hooks: + - id: blacken-docs + args: [--skip-errors] + additional_dependencies: [black==22.3.0] + language_version: python3