diff --git a/.github/labeler.yml b/.github/labeler.yml index 863a68f..00e4a89 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,32 +1,51 @@ 'module: methods': -- torchcam/methods/* +- changed-files: + - any-glob-to-any-file: torchcam/methods/* 'module: metrics': -- torchcam/metrics.py +- changed-files: + - any-glob-to-any-file: torchcam/metrics.py 'module: utils': -- torchcam/utils.py +- changed-files: + - any-glob-to-any-file: torchcam/utils.py 'ext: demo': -- demo/* +- changed-files: + - any-glob-to-any-file: demo/* 'ext: docs': -- docs/* +- changed-files: + - any-glob-to-any-file: docs/* 'ext: scripts': -- scripts/* +- changed-files: + - any-glob-to-any-file: scripts/* 'ext: tests': -- tests/* +- changed-files: + - any-glob-to-any-file: tests/* 'topic: ci': -- .github/* - -'topic: documentation': -- notebooks/* -- README.md -- CONTRIBUTING.md +- changed-files: + - any-glob-to-any-file: .github/* + +'topic: docs': +- changed-files: + - any-glob-to-any-file: + - notebooks/* + - README.md + - CONTRIBUTING.md + - CODFE_OF_CONDUCT.md + - CITATION.cff + - LICENSE 'topic: build': -- setup.py -- pyproject.toml +- changed-files: + - any-glob-to-any-file: + - setup.py + - pyproject.toml + +'topic: style': +- changed-files: + - any-glob-to-any-file: .pre-commit-config.yaml diff --git a/.github/verify_labels.py b/.github/verify_labels.py index 5db876d..b4474ef 100644 --- a/.github/verify_labels.py +++ b/.github/verify_labels.py @@ -1,4 +1,4 @@ -# Copyright (C) 2020-2023, François-Guillaume Fernandez. +# Copyright (C) 2020-2024, François-Guillaume Fernandez. # This program is licensed under the Apache License 2.0. # See LICENSE or go to for full license details. @@ -20,23 +20,25 @@ # Should specify the type of change PRIMARY_LABELS = { - "type: new feature", - "type: bug", - "type: enhancement", + "type: feat", + "type: fix", + "type: improvement", "type: misc", } # Should specify what has been modified SECONDARY_LABELS = { - "topic: documentation", - "module: methods", - "module: utils", + "topic: docs", + "topic: build", + "topic: ci", + "topic: style", "ext: demo", "ext: docs", "ext: scripts", "ext: tests", - "topic: build", - "topic: ci", + "module: methods", + "module: metrics", + "module: utils", } GH_ORG = "frgfm" diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml index 39e039b..9b3b6ed 100644 --- a/.github/workflows/pr-labels.yml +++ b/.github/workflows/pr-labels.yml @@ -10,17 +10,15 @@ jobs: if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Set up python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - name: Install requests run: pip install requests - name: Process commit and find merger responsible for labeling id: commit run: echo "::set-output name=merger::$(python .github/verify_labels.py ${{ github.event.pull_request.number }})" - name: Comment PR - uses: actions/github-script@0.3.0 + uses: actions/github-script@v7 if: ${{ steps.commit.outputs.merger != '' }} with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 57dade8..e3a4768 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -21,7 +21,7 @@ jobs: architecture: x64 - name: Run ruff run: | - pip install ruff==0.1.14 + pip install ruff==0.2.0 ruff --version ruff check --diff . @@ -65,7 +65,7 @@ jobs: architecture: x64 - name: Run ruff run: | - pip install ruff==0.1.14 + pip install ruff==0.2.0 ruff --version ruff format --check --diff . diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d94bf8a..ab42a34 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.1.14' + rev: 'v0.2.0' hooks: - id: ruff args: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a77a5d..4102ccc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,10 +90,8 @@ make quality ``` This will read `pyproject.toml` and run: -- lint checking ([ruff](https://docs.astral.sh/ruff/)) +- lint checking, formatting ([ruff](https://docs.astral.sh/ruff/)) - type annotation checking ([mypy](https://github.com/python/mypy)) -- code formatting ([black](https://github.com/psf/black)) -- security checking ([bandit](https://github.com/PyCQA/bandit)) You can apply automatic fix to most of those by running: diff --git a/pyproject.toml b/pyproject.toml index f9c3149..3879a84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ test = [ "pytest-pretty>=1.0.0,<2.0.0", ] quality = [ - "ruff==0.1.14", + "ruff==0.2.0", "mypy==1.8.0", "pre-commit>=3.0.0,<4.0.0", ] @@ -76,7 +76,7 @@ dev = [ "pytest-cov>=4.0.0,<5.0.0", "pytest-pretty>=1.0.0,<2.0.0", # style - "ruff==0.1.11", + "ruff==0.2.0", "mypy==1.8.0", "pre-commit>=3.0.0,<4.0.0", # docs @@ -108,6 +108,11 @@ testpaths = ["torchcam/"] source = ["torchcam/"] [tool.ruff] +line-length = 120 +target-version = "py39" +preview = true + +[tool.ruff.lint] select = [ "E", # pycodestyle errors "W", # pycodestyle warnings @@ -159,15 +164,15 @@ ignore = [ "ANN401", # Dynamically typed expressions (typing.Any) are disallowed ] exclude = [".git"] -line-length = 120 -target-version = "py39" -preview = true -[tool.ruff.format] -quote-style = "double" -indent-style = "space" +[tool.ruff.lint.flake8-quotes] +docstring-quotes = "double" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.isort] +known-first-party = ["torchcam", "app"] +known-third-party = ["torch", "torchvision"] + +[tool.ruff.lint.per-file-ignores] "**/__init__.py" = ["I001", "F401", "CPY001"] "scripts/**.py" = ["D", "T201", "N812", "S101", "ANN"] ".github/**.py" = ["D", "T201", "S602", "S101", "ANN"] @@ -176,12 +181,9 @@ indent-style = "space" "demo/**.py" = ["D103", "ANN"] "setup.py" = ["T201"] -[tool.ruff.flake8-quotes] -docstring-quotes = "double" - -[tool.ruff.isort] -known-first-party = ["torchcam", "app"] -known-third-party = ["torch", "torchvision"] +[tool.ruff.format] +quote-style = "double" +indent-style = "space" [tool.mypy] python_version = "3.9"