Skip to content

Commit 7aa1c09

Browse files
authored
Migrate to ruff and pre-commit (#17)
1 parent 4ed7301 commit 7aa1c09

28 files changed

+838
-1441
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
python-version: '3.10'
1515
- run: poetry install
1616
- uses: tschm/[email protected]
17-
id: mint
17+
id: mint
1818
- run: poetry publish --build -u __token__ -p $PYPI_TOKEN
1919
env:
2020
PYPI_TOKEN: ${{ steps.mint.outputs.api-token }}

.github/workflows/test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ jobs:
1010
strategy:
1111
matrix:
1212
action:
13-
- style
14-
- lint
1513
- test
1614
- coverage
1715
steps:
@@ -23,3 +21,10 @@ jobs:
2321
python-version: '3.10'
2422
- run: poetry install
2523
- run: poetry run poe ${{ matrix.action }}
24+
lint:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: pre-commit/[email protected]
29+
env:
30+
SKIP: poetry-lock

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-json
6+
- id: check-toml
7+
- id: check-yaml
8+
- id: end-of-file-fixer
9+
exclude: ^tests/.*\.data/
10+
- id: mixed-line-ending
11+
- id: trailing-whitespace
12+
- repo: https://github.com/python-poetry/poetry
13+
rev: 2.0.1
14+
hooks:
15+
- id: poetry-check
16+
- id: poetry-lock
17+
- repo: https://github.com/python-poetry/poetry
18+
rev: 2.0.1
19+
hooks:
20+
- id: poetry-install
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: v0.9.4
23+
hooks:
24+
- id: ruff
25+
args: [--fix, --exit-non-zero-on-fix]
26+
- id: ruff-format

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
<a href="https://www.gnu.org/licenses/gpl-3.0">
1111
<img alt="license" src="https://img.shields.io/badge/license-GPL3-blue.svg">
1212
</a>
13-
<a href="https://github.com/psf/black">
14-
<img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg">
15-
</a>
1613
</p>
1714

1815
## Description

blobopera/backend/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
"""
66

77
from .backend import Backend
8+
9+
__all__ = ["Backend"]

blobopera/command/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This file provides data import functions and some shared defaults and
44
enumerations used by choice-like subcommand options.
55
"""
6+
67
from enum import Enum
78
from typing import Type
89

@@ -73,8 +74,8 @@ class FillPhoneme(str, Enum):
7374
SILENCE = "SILENCE"
7475
A = "A"
7576
E = "E"
76-
I = "I"
77-
O = "O"
77+
I = "I" # noqa: E741
78+
O = "O" # noqa: E741
7879
U = "U"
7980

8081

blobopera/command/libretto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Inspect the default corpus of libretto texts."""
2+
23
import requests
34
import typer
45

blobopera/command/recording.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Operate with recording files and scores."""
2+
23
import tempfile
34
from pathlib import Path
45

@@ -149,7 +150,7 @@ def _import( # Prepend an underscore because import is a reserved keyword.
149150
tempo=tempo,
150151
parts=parts,
151152
fill=Phoneme[fill.value],
152-
location=Location[location.value]
153+
location=Location[location.value],
153154
)
154155

155156
output.write(

blobopera/jitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
be used to serialize and deserialize the ``jittertemplates.proto`` file from
66
the original Blob Opera application.
77
"""
8+
89
from functools import partial
910
from random import Random
1011
from typing import Any, Callable, Iterator
@@ -90,7 +91,6 @@ def __iter__(self) -> Iterator[float]:
9091

9192
# Iterate over randomly chosen templates with (previous, current) pairs
9293
for previous, current in pairwise(random): # (0, 1), (1, 2), (2, 3)...
93-
9494
# Get the tail (last values) of the previous template and the head
9595
# (first values) of the current template. Due to an off-by-one
9696
# error in the original code, the tail from the previous template

blobopera/languages/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
These modules provide parsers for converting lyrics from different languages
44
into sequences of phonemes following the Blob Opera phoneme format.
55
"""
6+
67
from .generic import GenericLanguage
78
from .language import Language
89
from .random import RandomLanguage
10+
11+
__all__ = ["GenericLanguage", "Language", "RandomLanguage"]

0 commit comments

Comments
 (0)