Skip to content

Commit

Permalink
Pre-Commits: Ruff
Browse files Browse the repository at this point in the history
Ruff is an extremely fast Python linter and code formatter. It replaces
tools such as autoflake, flake8, pyflakes, or pylint.
  • Loading branch information
ax3l committed Aug 14, 2024
1 parent 502e5ea commit c4cbe59
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 37 deletions.
46 changes: 9 additions & 37 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,44 +66,16 @@ repos:
# C++ formatting
# clang-format

# Autoremoves unused Python imports
- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
# Python: Ruff linter & formatter
# https://docs.astral.sh/ruff/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: pycln
name: pycln (python)

# Sorts Python imports according to PEP8
# https://www.python.org/dev/peps/pep-0008/#imports
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args: ['--profile black']

# Python: Flake8 (checks only, does this support auto-fixes?)
#- repo: https://github.com/PyCQA/flake8
# rev: 4.0.1
# hooks:
# - id: flake8
# additional_dependencies: &flake8_dependencies
# - flake8-bugbear
# - pep8-naming
# exclude: ^(docs/.*|tools/.*)$
# Alternatively: use autopep8?

# Python Formatting
#- repo: https://github.com/psf/black
# rev: 21.10b0 # Keep in sync with blacken-docs
# hooks:
# - id: black
#- repo: https://github.com/asottile/blacken-docs
# rev: v1.11.0
# hooks:
# - id: blacken-docs
# additional_dependencies:
# - black==21.10b0 # keep in sync with black hook
# Run the linter
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
# Run the formatter
- id: ruff-format

# Jupyter Notebooks: clean up all cell outputs
- repo: https://github.com/roy-ht/pre-commit-jupyter
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ requires = [
]
build-backend = "setuptools.build_meta"

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
select = ["E", "F", "I"]
ignore = ["E402", "E501", "F405"]

[tool.ruff.lint.isort]
known-first-party = ["amrex", "picmistandard", "pywarpx", "warpx"]

[tool.isort]
known_first_party = ["amrex", "picmistandard", "pywarpx", "warpx"]
profile = "black"

0 comments on commit c4cbe59

Please sign in to comment.