Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ruff formatter as pre-commit #133

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Version 1.21.0 (2023-12-06)
``audeer.mkdir()``,
``audeer.rmdir()``,
and ``audeer.touch()``.
Instead of writing ``audeer.mkdir(os.path.join('a', 'b'))``,
you can now write ``audeer.mkdir('a', 'b')``
Instead of writing ``audeer.mkdir(os.path.join("a", "b"))``,
you can now write ``audeer.mkdir("a", "b")``


Version 1.20.2 (2023-11-28)
Expand Down Expand Up @@ -90,7 +90,7 @@ Version 1.20.0 (2023-05-02)
* Fixed: ``audeer.replace_file_extension()``
now returns the original filename
when an empty new file extension is provided
instead of adding ``'.'`` at the end of the filename
instead of adding ``"."`` at the end of the filename
* Fixed: ``audeer.extract_archive()``
and ``audeer.extract_archives()``
now return normalized relative paths
Expand Down
5 changes: 3 additions & 2 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,7 +61,8 @@ 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::
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ that lists all WAV files in the ``data`` folder:

import audeer

files = audeer.list_file_names('data', filetype='wav')
files = audeer.list_file_names("data", filetype="wav")


.. _tqdm: https://tqdm.github.io/
Expand Down
1 change: 1 addition & 0 deletions audeer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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
5 changes: 3 additions & 2 deletions audeer/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class config:
for the progress bar::

import audeer

audeer.config.TQDM_COLUMNS = 50

"""
Expand All @@ -13,8 +14,8 @@ class config:
"""Length of progress bar description."""

TQDM_FORMAT = (
'{percentage:3.0f}%|{bar} [{elapsed}<{remaining}] '
'{desc:' + str(TQDM_DESCLEN) + '}'
"{percentage:3.0f}%|{bar} [{elapsed}<{remaining}] "
"{desc:" + str(TQDM_DESCLEN) + "}"
)
"""Format of progress bars."""

Expand Down
4 changes: 2 additions & 2 deletions audeer/core/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
@pytest.fixture(autouse=True)
def docdir(doctest_namespace, request):
# make sure audeer is imported
doctest_namespace['audeer'] = audeer
doctest_namespace["audeer"] = audeer
# set temporal working directory in docstring examples
tmpdir = request.getfixturevalue('tmpdir')
tmpdir = request.getfixturevalue("tmpdir")
with tmpdir.as_cwd():
yield
Loading