Skip to content

Commit

Permalink
Switch from black/isort/... to ruff
Browse files Browse the repository at this point in the history
WIP

- [ ] Apply changes after the bigger PRs have been merged to avoid conflicts.
- [ ] Re-enable some currently ignored rules
  • Loading branch information
dweindl committed Nov 12, 2024
1 parent 3708506 commit 6e31eef
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 55 deletions.
9 changes: 0 additions & 9 deletions .flake8

This file was deleted.

41 changes: 17 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,8 @@
# `pre-commit run --all-files` as by default only changed files are checked

repos:
- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
description: The uncompromising code formatter
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-black
- id: nbqa-pyupgrade
args: [--py36-plus]
- id: nbqa-isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-yaml
description: Check yaml files for parseable syntax
Expand All @@ -44,3 +21,19 @@ repos:
description: Fix empty lines at ends of files
- id: detect-private-key
description: Detects the presence of private keys
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
hooks:
# Run the linter.
- id: ruff
args:
- --fix
- --config
- pyproject.toml

# Run the formatter.
- id: ruff-format
args:
- --config
- pyproject.toml
49 changes: 42 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,47 @@ requires = [
]
build-backend = "setuptools.build_meta"

[tool.black]
[tool.ruff]
line-length = 79
target-version = ['py37', 'py38', 'py39']
skip-string-normalization = true
exclude = ["amici_models"]
extend-include = ["*.ipynb"]
lint.ignore = [
# FIXME: we should be able to remive move of those
"D103", # Missing docstring in public function
"S101", # Use of assert detected
"E501", # Line too long
"B028", # No explicit `stacklevel` keyword argument found
"C419", # Unnecessary list comprehension
"F403", # star import
"F821", # undefined name
"T201", # print statement
"S301", # pickle module used
"S102", # Use of exec detected
"S307", # Use of possibly insecure function
"B026", # Star-arg unpacking after a keyword argument
"B006",
"B027",
"C405",
"C416",
"E722",
"B904",
"B007",
"F841",
"B024",

[tool.isort]
profile = "black"
line_length = 79
multi_line_output = 3
]
lint.select = [
"F", # Pyflakes
"I", # isort
# "D", # pydocstyle (PEP 257) FIXME enable after https://github.com/PEtab-dev/petab_select/pull/67
"S", # flake8-bandit
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"T20", # flake8-print
"W", # pycodestyle Warnings
"E", # pycodestyle Errors
"UP", # pyupgrade
# "ANN", # flakes-annotations
]
[tool.ruff.lint.pydocstyle]
convention = "pep257"
15 changes: 0 additions & 15 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,3 @@ commands =
coverage report
description =
Test basic functionality

[testenv:flake8]
skip_install = true
deps =
flake8 >= 3.8.3
flake8-bandit >= 2.1.2
flake8-bugbear >= 20.1.4
flake8-colors >= 0.1.6
flake8-comprehensions >= 3.2.3
flake8-print >= 3.1.4
flake8-docstrings >= 1.6.0
commands =
flake8 petab_select test setup.py
description =
Run flake8 with various plugins.

0 comments on commit 6e31eef

Please sign in to comment.