Skip to content

Commit

Permalink
WIP Switch from flake8 to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
ushkarev committed Nov 16, 2023
1 parent 8b79f64 commit d7afc85
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
run: pip install -U setuptools pip wheel
- name: Install linting requirements
run: pip install -r requirements-lint.txt
- name: Lint code
run: flake8 --verbose
- name: Check code style
run: ruff check .
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help init clean test test-all coverage lint release
.PHONY: help init clean test test-all coverage lint format release

help:
@echo "Using make is entirely optional; these are simply shortcuts"
Expand All @@ -10,6 +10,7 @@ help:
@echo "test-all - run all tests in all supported python environments"
@echo "coverage - check code coverage while running all tests using current python environment"
@echo "lint - check code style"
@echo "format - fix code style"
@echo "release - NOT NORMALLY USED; See README.rst for release process"

init:
Expand Down Expand Up @@ -39,7 +40,11 @@ coverage:

lint:
pip install -r requirements-lint.txt
flake8 --verbose
ruff check .

format:
pip install -r requirements-lint.txt
ruff format .

release: clean
pip install -r requirements-release.txt
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ History

Unreleased
Migrated test, build and release processes away from deprecated setuptools commands.
Switched to `ruff <https://github.com/astral-sh/ruff>`_ for code linting and formatting.
No significant library changes.

0.8
Expand Down
24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.ruff]
exclude = [".git/", ".eggs/", ".tox/", "build/", "dist/", "env/", "venv/"]
indent-width = 4
line-length = 120

[tool.ruff.format]
indent-style = "space"
line-ending = "lf"
quote-style = "single"
skip-magic-trailing-comma = false

[tool.ruff.lint]
preview = true
select = ["B", "BLE", "C", "E", "F", "I", "PL", "PYI", "Q", "RUF", "S", "SIM", "T", "TCH", "TID", "UP", "W", "YTT"]

[tool.ruff.lint.flake8-quotes]
inline-quotes = "single"

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.lint.pylint]
max-args = 7
7 changes: 1 addition & 6 deletions requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
flake8
flake8-blind-except
flake8-bugbear
flake8-debugger
flake8-quotes
pep8-naming
ruff
5 changes: 0 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ install_requires =
Django>=2.2,<4.3
requests

[flake8]
exclude = .git/,.eggs/,.tox/,build/,dist/,env/,venv/
max-complexity = 10
max-line-length = 120

[coverage:run]
omit =
setup.py
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import setup

if sys.version_info[0:2] < (3, 8):
if sys.version_info[0:2] < (3, 8): # noqa: UP036
warnings.warn('This package is only tested on Python version 3.8+', stacklevel=1)

setup()
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ commands = python -m tests
[testenv:lint]
description = lint code
deps = -r requirements-lint.txt
commands = flake8 --verbose
commands = ruff check .

0 comments on commit d7afc85

Please sign in to comment.