Skip to content

Commit

Permalink
chore(deps): bump ruff to 0.2.0 (#235)
Browse files Browse the repository at this point in the history
* chore(deps): bump ruff to 0.2.0

* docs(contributing): fix the make quality command description

* ci(github): bumps ruff

* ci(github): Updates PR label triage & check
  • Loading branch information
frgfm authored Feb 4, 2024
1 parent 4302ee8 commit 91b7543
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 50 deletions.
49 changes: 34 additions & 15 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 11 additions & 9 deletions .github/verify_labels.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.apache.org/licenses/LICENSE-2.0> for full license details.
Expand All @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down Expand Up @@ -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 .
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
32 changes: 17 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand All @@ -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"
Expand Down

0 comments on commit 91b7543

Please sign in to comment.