Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Replaces flake8 by ruff and updates python version #211

Merged
merged 10 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ build:

requirements:
host:
- python>=3.6, <4.0
- python>=3.8, <4.0
- setuptools

run:
Expand Down
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [3.7, 3.8]
python: [3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: [3.7, 3.8]
python: [3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/doc-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
see-page-build-payload:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.7
uses: actions/setup-python@v1
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
architecture: x64
- name: check status
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
- name: Install requests
run: pip install requests
- name: Process commit and find merger responsible for labeling
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
architecture: x64
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
architecture: x64
Expand Down Expand Up @@ -44,8 +44,8 @@ jobs:
needs: pypi-publish
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
architecture: x64
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: main

jobs:
flake8:
ruff:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -16,15 +16,15 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run flake8
- name: Run ruff
run: |
pip install flake8
flake8 --version
flake8
pip install ruff
ruff --version
ruff check --diff .

isort:
runs-on: ${{ matrix.os }}
Expand All @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand All @@ -55,7 +55,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand All @@ -102,13 +102,13 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run black
run: |
pip install black
pip install "black==22.3.0"
black --version
black --check --diff .

Expand All @@ -121,7 +121,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
Expand Down
14 changes: 6 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: debug-statements
language_version: python3
- id: check-merge-conflict
- id: no-commit-to-branch
args: ['--branch', 'main']
Expand All @@ -22,12 +23,9 @@ repos:
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
exclude: "(__init__.py)$"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.260'
hooks:
- id: flake8
exclude: docs
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
- id: autoflake
- id: ruff
exclude: "(__init__.py)$"
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# this target runs checks on all files
quality:
isort . -c
flake8
ruff check .
mypy
pydocstyle
black --check .
bandit -r . -c pyproject.toml
autoflake -r .

# this target runs checks on all files and potentially modifies some of them
style:
isort .
black .
autoflake --in-place -r .
ruff --fix .

# Run tests for the library
test:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ plt.imshow(result); plt.axis('off'); plt.tight_layout(); plt.show()

## Setup

Python 3.6 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install TorchCAM.
Python 3.8 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install TorchCAM.

### Stable release

Expand Down
2 changes: 1 addition & 1 deletion docs/source/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation
************

This library requires `Python <https://www.python.org/downloads/>`_ 3.6 or higher.
This library requires `Python <https://www.python.org/downloads/>`_ 3.8 or higher.

Via Python Package
==================
Expand Down
42 changes: 24 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
{name = "François-Guillaume Fernandez", email = "fg-feedback@protonmail.com"}
]
readme = "README.md"
requires-python = ">=3.6,<4"
requires-python = ">=3.8,<4"
license = {file = "LICENSE"}
keywords = ["pytorch", "deep learning", "class activation map", "cnn", "gradcam"]
classifiers = [
Expand All @@ -20,10 +20,9 @@ classifiers = [
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
Expand All @@ -46,12 +45,11 @@ test = [
"torchvision>=0.4.0,<1.0.0",
]
quality = [
"flake8>=3.9.0",
"ruff>=0.0.260,<1.0.0",
"isort>=5.7.0",
"mypy>=0.812",
"mypy>=1.2.0",
"pydocstyle[toml]>=6.0.0",
"black>=22.1,<23.0",
"autoflake>=1.5.0,<2.0.0",
"black==22.3.0",
"bandit[toml]>=1.7.0,<1.8.0",
"pre-commit>=2.17.0,<3.0.0",
]
Expand All @@ -77,11 +75,13 @@ dev = [
"requests>=2.20.0,<3.0.0",
"torchvision>=0.4.0,<1.0.0",
# style
"flake8>=3.9.0",
"ruff>=0.0.260,<1.0.0",
"isort>=5.7.0",
"mypy>=0.812",
"mypy>=1.2.0",
"pydocstyle[toml]>=6.0.0",
"black>=22.1,<23.0",
"black==22.3.0",
"bandit[toml]>=1.7.0,<1.8.0",
"pre-commit>=2.17.0,<3.0.0",
# docs
"sphinx>=3.0.0,!=3.5.0",
"furo>=2022.3.4",
Expand All @@ -104,6 +104,20 @@ zip-safe = true
[tool.setuptools.packages.find]
exclude = ["demo*", "docs*", "notebooks*", "scripts*", "tests*"]

[tool.coverage.run]
source = ["torchcam"]

[tool.ruff]
ignore = ["E402", "F403", "E731"]
exclude = [".git", "venv*", "build", "docs"]
line-length = 120
target-version = "py38"

[tool.ruff.per-file-ignores]
"**/__init__.py" = ["F401"]

[tool.ruff.flake8-quotes]
docstring-quotes = "double"

[tool.mypy]
files = "torchcam/"
Expand Down Expand Up @@ -134,18 +148,10 @@ known_third_party = ["torch", "torchvision"]
select = "D300,D301,D417"
match = ".*\\.py"

[tool.coverage.run]
source = ["torchcam"]

[tool.black]
line-length = 120
target-version = ['py38']

[tool.autoflake]
remove-unused-variables = true
remove-all-unused-imports = true
ignore-init-module-imports = true

[tool.bandit]
exclude_dirs = [".github/collect_env.py"]
skips = ["B101"]
Loading