Skip to content

Commit

Permalink
Switched linters to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
spookylukey committed Apr 30, 2024
1 parent b75f399 commit 50f1c03
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 98 deletions.
46 changes: 5 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,14 @@ jobs:
run: |
./runtests.py --use-tz=false
flake8:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ '3.9' }}-${{ hashFiles('requirements*.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -r requirements-dev.txt
- name: Lint with flake8
run: |
flake8 --version
flake8 .
isort:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ '3.9' }}-${{ hashFiles('requirements*.txt') }}
- name: Install deps
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -r requirements-dev.txt
- name: Run isort
run: |
isort --version
isort -c .
python-version: "3.10"
- uses: pre-commit/action@v3.0.0

check-manifest:
runs-on: ubuntu-latest
Expand Down
35 changes: 4 additions & 31 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,17 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: 'https://github.com/pycqa/flake8'
rev: 3.9.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.2
hooks:
- id: flake8
- repo: 'https://github.com/pre-commit/mirrors-isort'
rev: v5.10.1
hooks:
- id: isort
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: 'https://github.com/mgedmin/check-manifest'
rev: '0.48'
hooks:
- id: check-manifest
- repo: 'https://github.com/myint/autoflake'
rev: v2.0.0
hooks:
- id: autoflake
args:
- '--remove-all-unused-imports'
- '-i'
language_version: python3.9
- repo: 'https://github.com/pre-commit/mirrors-autopep8'
rev: v2.0.0
hooks:
- id: autopep8
language_version: python3.9
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language_version: python3.9
- repo: https://github.com/ikamensh/flynt/
rev: '0.77'
hooks:
- id: flynt
language_version: python3.9
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
entry: pyupgrade --py3-plus --py36-plus --keep-runtime-typing
language_version: python3.9
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ Development environment

4. Install development tools::

pip install tox isort flake8
pip install -r requirements-test.txt -r requirements-dev.txt

5. Recommended: Install `pre-commit <https://pre-commit.com/>`_ and set up
5. Strongly recommended: Install `pre-commit <https://pre-commit.com/>`_ and set up
the hooks::

pre-commit install

This will run flake8/isort automatically when you commit.
This will run linters automatically when you commit.

Code quality
~~~~~~~~~~~~
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ default_section= "THIRDPARTY"
forced_separate = ["paypal.pro.tests", "paypal.standard.ipn.tests", "paypal.standard.pdt.tests"]
skip = [".tox", "dist", "build", ".git"]
skip_glob = ["**/migrations/*.py"]

[tool.ruff]
line-length = 120
target-version = 'py37'

[tool.ruff.lint]
extend-select = [
"UP", # enable pyupgrade
"I", # enable isort
"FLY", # enable flynt
]
ignore = [
"E731",
"UP031",
]
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flake8==3.8.4
isort==5.7.0
check-manifest
twine
ruff
tox
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[flake8]
exclude = .tox,.git,docs,*/migrations/*,dist,build,.ropeproject
ignore = E123,E128,E731,W504,W503
max-line-length = 120
18 changes: 1 addition & 17 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ envlist =
py310-django40
py311-django42
py312-django50
checkmanifest, isort-check, flake8-check
checkmanifest

[testenv]
commands =
Expand All @@ -38,19 +38,3 @@ deps =
check-manifest
Django
commands = check-manifest

[testenv:isort-check]
# isort configurations are located in setup.cfg
basepython = python3.9
deps =
-r requirements-dev.txt
Django
commands = isort -rc -c {toxinidir}

[testenv:flake8-check]
# flake8 configurations are located in setup.cfg
basepython = python3.9
deps =
-r requirements-dev.txt
Django
commands = flake8

0 comments on commit 50f1c03

Please sign in to comment.