Skip to content

Commit

Permalink
Add ruff and remove the packages it replaces
Browse files Browse the repository at this point in the history
This commit implements the ruff linter/formater and
removes the old dependencies it replaces.
  • Loading branch information
elevans committed Oct 14, 2024
1 parent e300a5a commit 4310fe3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 54 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,11 @@ jobs:
- uses: actions/setup-python@v3

- name: Lint code
uses: psf/black@stable

- name: Flake code
run: |
python -m pip install flake8 Flake8-pyproject flake8-typing-imports
python -m flake8 src tests
- name: Check import ordering
uses: isort/isort-action@master
with:
configuration: --check-only

python -m pip install ruff
ruff check
ruff format --check
- name: Validate pyproject.toml
run: |
python -m pip install validate-pyproject[all]
Expand Down
28 changes: 8 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
repos:
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args: ["--in-place", "--remove-all-unused-imports"]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- "flake8-typing-imports"
- "Flake8-pyproject"
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
# ruff version
rev: v0.6.2
hooks:
# run the linter
- id: ruff
# run the formatter
- id: ruff-format
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.10.1
hooks:
Expand Down
7 changes: 1 addition & 6 deletions dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,17 @@ dependencies:
- pooch # for scikit image
- scikit-image
# Developer tools
- autopep8
- black
- flake8
- flake8-typing-imports
- isort
- myst-nb
- pre-commit
- python-build
- pytest
- pytest-cov
- ruff
- sphinx
- sphinx_rtd_theme
- pip
- pip:
- readthedocs-sphinx-search
- flake8-pyproject
- validate-pyproject[all]
# Project from source
- -e .
28 changes: 11 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,12 @@ dependencies = [
# NB: Keep this in sync with dev-environment.yml!
# Development tools
dev = [
"autopep8",
"black",
"build",
"flake8",
"flake8-pyproject",
"flake8-typing-imports",
"isort",
"myst-nb",
"pre-commit",
"pytest",
"pytest-cov",
"ruff",
"sphinx",
"sphinx_rtd_theme",
"validate-pyproject[all]",
Expand Down Expand Up @@ -96,20 +91,19 @@ include-package-data = false
where = ["src"]
namespaces = false

[tool.black]
exclude = 'dist|doc'
# ruff configuration
[tool.ruff]
line-length = 88
src = ["src", "tests"]
include = ["pyproject.toml", "src/**/*.py", "tests/**/*.py"]
extend-exclude = ["bin", "build", "dist"]

# Thanks to Flake8-pyproject, we can configure flake8 here!
[tool.flake8]
exclude = ["build", "dist", "doc"]
[tool.ruff.lint]
extend-ignore = ["E203"]
# See https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
max-line-length = 88
min_python_version = "3.8"

[tool.isort]
profile = "black"
skip = ["doc"]
[tool.ruff.lint.per-file-ignores]
# Ignore `E402` (import violations) in all `__init__.py` files, and in `path/to/file.py`.
"__init__.py" = ["E402", "F401"]

[tool.pytest.ini_options]
addopts = "--ignore=docs"

0 comments on commit 4310fe3

Please sign in to comment.