diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index b164a51..f5a0fdb 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -3,106 +3,6 @@ name: default on: [push, pull_request] jobs: - lint-flake8: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10.8" - cache: pip - cache-dependency-path: | - setup.py - requirements/lint.txt - - name: Install dependencies - run: | - python -m pip install -U pip setuptools wheel - python -m pip install -U -r requirements/lint.txt - - name: Lint with flake8 - run: | - if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then - echo "(skipping matchers for pull request from local branches)" - else - echo "::add-matcher::.github/workflows/flake8-matcher.json" - fi - python -m flake8 src tests setup.py - - lint-black: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10.8" - cache: pip - cache-dependency-path: | - setup.py - requirements/lint.txt - - name: Install dependencies - run: | - python -m pip install -U pip setuptools wheel - python -m pip install -U -r requirements/lint.txt - - name: Lint with black - run: | - python -m black --check src tests setup.py - - lint-isort: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10.8" - cache: pip - cache-dependency-path: | - setup.py - requirements/lint.txt - - name: Install dependencies - run: | - python -m pip install -U pip setuptools wheel - python -m pip install -U -r requirements/lint.txt - - name: Lint with isort - run: | - python -m isort --check src tests setup.py - - typecheck-mypy: - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.10.8" - cache: pip - cache-dependency-path: | - setup.py - requirements/typecheck.txt - - name: Install dependencies - run: | - python -m pip install -U pip setuptools wheel - python -m pip install -U -r requirements/typecheck.txt - - name: Type check with mypy - run: | - if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then - echo "(skipping matchers for pull request from local branches)" - else - echo "::add-matcher::.github/workflows/mypy-matcher.json" - fi - python -m mypy --no-color-output src/callosum test-unit: @@ -124,7 +24,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10.8" + python-version: "3.11.4" cache: pip cache-dependency-path: | setup.py @@ -162,7 +62,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10.8" + python-version: "3.11.4" cache: pip cache-dependency-path: | setup.py @@ -191,7 +91,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10.8" + python-version: "3.11.4" cache: pip cache-dependency-path: | setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d47fef2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +ci: + autoupdate_schedule: quarterly +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.287 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.5.1 + hooks: + - id: mypy diff --git a/requirements/dev.txt b/requirements/dev.txt index 55cca3b..880389e 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1 +1 @@ --e .[build,lint,typecheck,test] +-e .[build,dev,lint,typecheck,test] diff --git a/setup.py b/setup.py index ab58366..85002e7 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,7 @@ def read_src_version(): dev_requires: List[str] = [ # 'pytest-sugar', + "pre-commit", ] lint_requires = [