Skip to content

Commit

Permalink
Use ruff formatter as pre-commit (#65)
Browse files Browse the repository at this point in the history
* Use ruff formatter as pre-commit

* Update usage docs
  • Loading branch information
hagenw authored Apr 26, 2024
1 parent 71f91bc commit 57d108c
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 240 deletions.
10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'

- name: Install pre-commit hooks
run: |
Expand Down
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
#
#
default_language_version:
python: python3.8
python: python3.10

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.276
rev: v0.1.8
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Coding Convention
-----------------

We follow the PEP8_ convention for Python code
and check for correct syntax with ruff_.
and use ruff_ as a linter and code formatter.
In addition,
we check for common spelling errors with codespell_.
Both tools and possible exceptions
Expand All @@ -61,13 +61,14 @@ You can also install ruff_ and codespell_
and call it directly::

pip install ruff codespell # consider system wide installation
ruff check .
ruff check --fix . # lint all Python files, and fix any fixable errors
ruff format . # format code of all Python files
codespell

It can be restricted to specific folders::

ruff check audfoo/ tests/
codespell audfoo/ tests/
ruff check audplot/ tests/
codespell audplot/ tests/


.. _codespell: https://github.com/codespell-project/codespell/
Expand Down
1 change: 1 addition & 0 deletions audplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Dynamically get the version of the installed module
try:
import importlib.metadata

__version__ = importlib.metadata.version(__name__)
except Exception: # pragma: no cover
importlib = None # pragma: no cover
Expand Down
Loading

0 comments on commit 57d108c

Please sign in to comment.