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

[misc & build] replace isort pydocstyle and black with ruff #1379

Merged
merged 16 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
3 changes: 1 addition & 2 deletions .github/verify_pr_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# This program is licensed under the Apache License 2.0.
# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.

"""
Borrowed & adapted from https://github.com/pytorch/vision/blob/main/.github/process_commit.py
"""Borrowed & adapted from https://github.com/pytorch/vision/blob/main/.github/process_commit.py
This script finds the merger responsible for labeling a PR by a commit SHA. It is used by the workflow in
'.github/workflows/pr-labels.yml'. If there exists no PR associated with the commit or the PR is properly labeled,
this script is a no-op.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python: ["3.8", "3.9"]
python: ["3.9", "3.10"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down
4 changes: 2 additions & 2 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.8
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.9"
architecture: x64
- name: check status
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/public_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
# Must match version at https://www.python.org/ftp/python/
python: ["3.8.18", "3.9.18", "3.10.13"]
python: ["3.9.18", "3.10.13", "3.11.6"]
framework: ["tf", "torch"]
system: ["cpu", "gpu"]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.9"
architecture: x64
- name: Cache python modules
uses: actions/cache@v3
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -263,7 +263,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [tensorflow, pytorch]
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
framework: [pytorch]
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
needs: pypi-publish
steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8", "3.9"]
python: ["3.9", "3.10"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8", "3.9"]
python: ["3.9", "3.10"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ["3.8", "3.9"]
python: ["3.9", "3.10"]
framework: [tensorflow, pytorch]
steps:
- if: matrix.os == 'macos-latest'
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.8", "3.9"]
python: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand Down
62 changes: 2 additions & 60 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -26,51 +26,12 @@ jobs:
ruff --version
ruff check --diff .

black:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run black
run: |
pip install black
black --version
black --check --diff .

isort:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run isort
run: |
pip install isort
isort --version
isort .
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then exit 1; else echo "All clear"; fi

mypy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
python: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -92,22 +53,3 @@ jobs:
run: |
mypy --version
mypy

pydocstyle:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64
- name: Run pydocstyle
run: |
pip install pydocstyle[toml]
pydocstyle --version
pydocstyle
16 changes: 5 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-yaml
Expand All @@ -15,15 +15,9 @@ repos:
- id: check-merge-conflict
- id: no-commit-to-branch
args: ['--branch', 'main']
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.260'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
.PHONY: quality style test test-common test-tf test-torch docs-single-version docs
# this target runs checks on all files
quality:
isort . -c
ruff check .
black --check .
mypy doctr/
pydocstyle doctr/

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

# 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 @@ -134,7 +134,7 @@ The KIE predictor results per page are in a dictionary format with each key repr

### Prerequisites

Python 3.8 (or higher) and [pip](https://pip.pypa.io/en/stable/) are required to install docTR.
Python 3.9 (or higher) and [pip](https://pip.pypa.io/en/stable/) are required to install docTR.

Since we use [weasyprint](https://weasyprint.org/), you will need extra dependencies if you are not running Linux.

Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from doctr.utils.metrics import box_iou


@pytest.mark.asyncio
@pytest.mark.asyncio()
felixdittrich92 marked this conversation as resolved.
Show resolved Hide resolved
async def test_text_detection(test_app_asyncio, mock_detection_image):
response = await test_app_asyncio.post("/detection", files={"file": mock_detection_image})
assert response.status_code == 200
Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/test_kie.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from doctr.utils.metrics import box_iou


@pytest.mark.asyncio
@pytest.mark.asyncio()
async def test_perform_kie(test_app_asyncio, mock_detection_image):
response = await test_app_asyncio.post("/kie", files={"file": mock_detection_image})
assert response.status_code == 200
Expand Down
Loading
Loading