Skip to content

Commit

Permalink
Add ruff formatter/linter
Browse files Browse the repository at this point in the history
* Added to pre-commit
* Added VS Code extension
* Adjusted rules to allow existing code base
* Removed isort, black, and flake8 pre-commit hooks
  • Loading branch information
jhollowe committed Apr 4, 2024
1 parent d7419ab commit 841d55e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"charliermarsh.ruff",
"mhutchie.git-graph",
"ms-python.python",
"njpwerner.autodocstring",
Expand Down
36 changes: 12 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
repos:
###### FORMATTING ######
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.11.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.5
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
# Run the linter.
- id: ruff
name: ruff lint
types_or: [ python, pyi, jupyter ]
args: [ --fix ]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (pyi)
types: [pyi]
# Run the formatter.
- id: ruff-format
name: ruff format
types_or: [ python, pyi, jupyter ]

###### LINTING ######
- repo: https://github.com/PyCQA/bandit
Expand All @@ -22,18 +22,6 @@ repos:
- id: bandit
args: ["--configfile", ".bandit", "--baseline", "tests/known_issues.json"]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
# any flake8 plugins must be included in the hook venv
# additional_dependencies: [flake8-docstrings]

# - repo: https://github.com/PyCQA/pylint
# rev: v2.8.2
# hooks:
# - id: pylint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand Down
18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
[tool.black]
[tool.ruff]
line-length = 100
target-version = ['py37']
exclude = [".git", "__pycache__", "old", "build", "dist", "*.egg-info"]

[tool.ruff.lint]
# https://docs.astral.sh/ruff/rules/
select = ["F", "T20", "PL", "I"]
ignore = ["PLR0913", "PLR2004", "PLR0912"]

[tool.ruff.lint.per-file-ignores]
"**/tests/*" = ["F811"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true
docstring-code-line-length = "dynamic"

0 comments on commit 841d55e

Please sign in to comment.