From eb0e46e6c811ba915cac65d040f8fa2746164c15 Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Sun, 7 Jan 2024 18:24:28 +0100 Subject: [PATCH] style: Bumps ruff to 0.1.11 (#229) * chore: Bumps ruff to 0.1.11 * style: Updates precommits * ci: Updates CI dep installation * style: Updates precommit config * docs: Updates copyright notice * ci: Adds a job for precommit --- .github/workflows/style.yml | 23 +++++++++++++++++++++-- .pre-commit-config.yaml | 22 +++++++++++++--------- demo/app.py | 2 +- docs/source/conf.py | 2 +- pyproject.toml | 4 ++-- scripts/cam_example.py | 2 +- scripts/eval_latency.py | 2 +- scripts/eval_perf.py | 2 +- setup.py | 2 +- torchcam/methods/_utils.py | 2 +- torchcam/methods/activation.py | 2 +- torchcam/methods/core.py | 2 +- torchcam/methods/gradient.py | 2 +- torchcam/metrics.py | 11 ++++++++++- torchcam/utils.py | 2 +- 15 files changed, 57 insertions(+), 25 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 30c7a21..7323d5b 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.9 + pip install ruff==0.1.11 ruff --version ruff check --diff . @@ -65,6 +65,25 @@ jobs: architecture: x64 - name: Run ruff run: | - pip install ruff==0.1.9 + pip install ruff==0.1.11 ruff --version ruff format --check --diff . + + precommit-hooks: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python: [3.9] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x64 + - name: Run ruff + run: | + pip install pre-commit + pre-commit install + pre-commit --version + pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e5775b..219249a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,23 +2,27 @@ default_language_version: python: python3.9 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - - id: check-yaml - exclude: .conda - - id: check-toml - id: check-added-large-files - - id: end-of-file-fixer - - id: trailing-whitespace - id: check-ast + - id: check-case-conflict - id: check-json - id: check-merge-conflict - - id: no-commit-to-branch - args: ['--branch', 'main'] + - id: check-symlinks + - id: check-toml + - id: check-xml + - id: check-yaml + exclude: .conda - id: debug-statements language_version: python3 + - id: end-of-file-fixer + - id: no-commit-to-branch + args: ['--branch', 'main'] + - id: requirements-txt-fixer + - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.1.9' + rev: 'v0.1.11' hooks: - id: ruff args: diff --git a/demo/app.py b/demo/app.py index 092fcf9..9d390d9 100644 --- a/demo/app.py +++ b/demo/app.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2023, François-Guillaume Fernandez. +# Copyright (C) 2021-2024, François-Guillaume Fernandez. # This program is licensed under the Apache License 2.0. # See LICENSE or go to for full license details. diff --git a/docs/source/conf.py b/docs/source/conf.py index d9c8670..762ae7b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.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. diff --git a/pyproject.toml b/pyproject.toml index 298b318..ee87c58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ test = [ "pytest-pretty>=1.0.0,<2.0.0", ] quality = [ - "ruff==0.1.9", + "ruff==0.1.11", "mypy==1.8.0", "pre-commit>=3.0.0,<4.0.0", ] @@ -78,7 +78,7 @@ dev = [ "pytest-xdist>=3.0.0,<4.0.0", "pytest-pretty>=1.0.0,<2.0.0", # style - "ruff==0.1.9", + "ruff==0.1.11", "mypy==1.8.0", "pre-commit>=3.0.0,<4.0.0", # docs diff --git a/scripts/cam_example.py b/scripts/cam_example.py index 7eb6bcd..b395267 100644 --- a/scripts/cam_example.py +++ b/scripts/cam_example.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. diff --git a/scripts/eval_latency.py b/scripts/eval_latency.py index 9a5f1d4..89e4675 100644 --- a/scripts/eval_latency.py +++ b/scripts/eval_latency.py @@ -1,4 +1,4 @@ -# Copyright (C) 2021-2023, François-Guillaume Fernandez. +# Copyright (C) 2021-2024, François-Guillaume Fernandez. # This program is licensed under the Apache License 2.0. # See LICENSE or go to for full license details. diff --git a/scripts/eval_perf.py b/scripts/eval_perf.py index 35c5ffb..8ca83e6 100644 --- a/scripts/eval_perf.py +++ b/scripts/eval_perf.py @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2023, François-Guillaume Fernandez. +# Copyright (C) 2022-2024, François-Guillaume Fernandez. # This program is licensed under the Apache License 2.0. # See LICENSE or go to for full license details. diff --git a/setup.py b/setup.py index 681b76a..f5ccee8 100644 --- a/setup.py +++ b/setup.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. diff --git a/torchcam/methods/_utils.py b/torchcam/methods/_utils.py index 4d575f9..91757a9 100644 --- a/torchcam/methods/_utils.py +++ b/torchcam/methods/_utils.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. diff --git a/torchcam/methods/activation.py b/torchcam/methods/activation.py index fd9f2f7..b7e76e1 100644 --- a/torchcam/methods/activation.py +++ b/torchcam/methods/activation.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. diff --git a/torchcam/methods/core.py b/torchcam/methods/core.py index c08f05f..8d12d69 100644 --- a/torchcam/methods/core.py +++ b/torchcam/methods/core.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. diff --git a/torchcam/methods/gradient.py b/torchcam/methods/gradient.py index c51106f..887a454 100644 --- a/torchcam/methods/gradient.py +++ b/torchcam/methods/gradient.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. diff --git a/torchcam/metrics.py b/torchcam/metrics.py index 877c411..8f2e6a2 100644 --- a/torchcam/metrics.py +++ b/torchcam/metrics.py @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2023, François-Guillaume Fernandez. +# Copyright (C) 2022-2024, François-Guillaume Fernandez. # This program is licensed under the Apache License 2.0. # See LICENSE or go to for full license details. @@ -57,6 +57,7 @@ def __init__( cam_extractor: _CAM, logits_fn: Union[Callable[[torch.Tensor], torch.Tensor], None] = None, ) -> None: + # This is a typa, I don't know how to rites self.cam_extractor = cam_extractor self.logits_fn = logits_fn self.reset() @@ -65,6 +66,14 @@ def _get_probs(self, input_tensor: torch.Tensor) -> torch.Tensor: logits = self.cam_extractor.model(input_tensor) return cast(torch.Tensor, logits if self.logits_fn is None else self.logits_fn(logits)) + def my_function(self) -> str: + """Returns a greeting message + + Returns: + str: greeting message + """ + return "Hello" + def update( self, input_tensor: torch.Tensor, diff --git a/torchcam/utils.py b/torchcam/utils.py index 8428baa..17f79ae 100644 --- a/torchcam/utils.py +++ b/torchcam/utils.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.