Skip to content

Commit 83157ca

Browse files
authored
Flake to ruff (#84)
Migrated from flake8 to ruff for linting and formatting, updating CI workflows, adding new automation for changelog reminders, and improving contributor documentation. The change aligns our formatting and linting for this project with beets. We still use tox for testing but removed the the flake8 part of it entirely.
2 parents c975e07 + 32dc6c1 commit 83157ca

File tree

13 files changed

+1407
-1357
lines changed

13 files changed

+1407
-1357
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Migrated to ruff
2+
7ff9d471b23c45b6d957e7507035af39885546ab

.github/workflows/build.yml

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,46 @@ name: Build
33
on:
44
push:
55
branches:
6-
- master
6+
- master
77
pull_request:
88
branches:
99
- master
1010

1111
jobs:
1212
test:
13-
name: '${{ matrix.os }}: ${{ matrix.tox-env }}'
13+
name: "${{ matrix.os }}: ${{ matrix.tox-env }}"
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
tox-env: [py37-test, py38-test, py39-test,
19-
py310-test, pypy-test]
20-
os: [ubuntu-22.04, windows-latest]
18+
tox-env:
19+
[
20+
py39-test,
21+
py310-test,
22+
py311-test,
23+
py312-test,
24+
py313-test,
25+
pypy-test,
26+
]
27+
os: [ubuntu-24.04, windows-latest]
2128

2229
# Only test on a couple of versions on Windows.
2330
exclude:
24-
- os: windows-latest
25-
tox-env: py37-test
2631
- os: windows-latest
2732
tox-env: pypy-test
2833

2934
# Python interpreter versions. :/
3035
include:
31-
- tox-env: py37-test
32-
python: '3.7'
33-
- tox-env: py38-test
34-
python: '3.8'
3536
- tox-env: py39-test
36-
python: '3.9'
37+
python: "3.9"
3738
- tox-env: py310-test
38-
python: '3.10'
39+
python: "3.10"
40+
- tox-env: py311-test
41+
python: "3.11"
42+
- tox-env: py312-test
43+
python: "3.12"
44+
- tox-env: py313-test
45+
python: "3.13"
3946
- tox-env: pypy-test
4047
python: pypy3.9
4148

@@ -54,5 +61,20 @@ jobs:
5461
name: Style
5562
runs-on: ubuntu-latest
5663
steps:
57-
- uses: actions/checkout@v2
58-
- uses: TrueBrain/actions-flake8@master
64+
- uses: actions/checkout@v4
65+
- name: Install Python
66+
uses: actions/setup-python@v5
67+
with:
68+
python-version: "3.9"
69+
- name: Install dependencies
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install .[dev]
73+
- name: Check style with Ruff
74+
id: ruff
75+
run: |
76+
ruff check --output-format=github .
77+
- name: Check format with Ruff
78+
id: ruff-format
79+
run: |
80+
ruff format --check .
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Verify changelog updated
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- ready_for_review
8+
9+
jobs:
10+
check_changes:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Get all updated Python files
16+
id: changed-python-files
17+
uses: tj-actions/changed-files@v46
18+
with:
19+
files: |
20+
**.py
21+
22+
- name: Check for the changelog update
23+
id: changelog-update
24+
uses: tj-actions/changed-files@v46
25+
with:
26+
files: docs/changelog.rst
27+
28+
- name: Comment under the PR with a reminder
29+
if: steps.changed-python-files.outputs.any_changed == 'true' && steps.changelog-update.outputs.any_changed == 'false'
30+
uses: thollander/actions-comment-pull-request@v2
31+
with:
32+
message: "Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry."
33+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contributing to mediafile
2+
3+
First off, thanks for taking the time to contribute! ❤️
4+
5+
Please follow these guidelines to ensure a smooth contribution process.
6+
7+
## Pre-requisites
8+
9+
- Python 3.9 or higher
10+
- Git
11+
12+
## Setup the Development Environment
13+
14+
We recommend using a virtual environment to manage dependencies. You can use `venv`, `conda`, or any other tool of your choice.
15+
16+
1. Fork/Clone the repository on GitHub
17+
```bash
18+
git clone <your-fork-url>
19+
cd mediafile
20+
```
21+
2. Install dependencies and set up the development environment
22+
```bash
23+
pip install -e '.[dev]'
24+
```
25+
26+
## Before submitting a Pull Request
27+
28+
Verify that your code adheres to the project standards and conventions. Run
29+
ruff and pytest to ensure your code is properly formatted and all tests pass.
30+
31+
```bash
32+
ruff check .
33+
ruff format .
34+
pytest .
35+
```

docs/changelog.rst

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
Changelog
2+
---------
3+
4+
Upcoming
5+
''''''''
6+
7+
- Dropped support for Python 3.7 and 3.8
8+
- Added minimal contribution guidelines to CONTRIBUTING.md
9+
- Changed project linter and formatter from ``flake8`` to ``ruff``. Reformatted
10+
the codebase with ``ruff``.
11+
- Moved changelog into its own file, ``changelog.rst``. Also added github workflow
12+
for automatic changelog reminders.
13+
14+
v0.13.0
15+
'''''''
16+
17+
- Add a mapping compatible with Plex and ffmpeg for the "original date"
18+
fields.
19+
- Remove an unnecessary dependency on `six`.
20+
- Replace `imghdr` with `filetype` to support Python 3.13.
21+
22+
v0.12.0
23+
'''''''
24+
25+
- Add the multiple-valued properties ``artists_credit``, ``artists_sort``,
26+
``albumartists_credit``, and ``albumartists_sort``.
27+
28+
v0.11.0
29+
'''''''
30+
31+
- List-valued properties now return ``None`` instead of an empty list when the
32+
underlying tags are missing altogether.
33+
34+
v0.10.1
35+
'''''''
36+
37+
- Fix a test failure that arose with Mutagen 1.46.
38+
- Require Python 3.7 or later.
39+
40+
v0.10.0
41+
'''''''
42+
43+
- Add the multiple-valued properties ``albumtypes``, ``catalognums`` and
44+
``languages``.
45+
- The ``catalognum`` property now refers to additional file tags named
46+
``CATALOGID`` and ``DISCOGS_CATALOG`` (but only for reading, not writing).
47+
- The multi-valued ``albumartists`` property now refers to additional file
48+
tags named ``ALBUM_ARTIST`` and ``ALBUM ARTISTS``. (The latter
49+
is used only for reading.)
50+
- The ``ListMediaField`` class now doesn't concatenate multiple lists if
51+
found. The first available tag is used instead, like with other kinds of
52+
fields.
53+
54+
v0.9.0
55+
''''''
56+
57+
- Add the properties ``bitrate_mode``, ``encoder_info`` and
58+
``encoder_settings``.
59+
60+
v0.8.1
61+
''''''
62+
63+
- Fix a regression in v0.8.0 that caused a crash on Python versions below 3.8.
64+
65+
v0.8.0
66+
''''''
67+
68+
- MediaFile now requires Python 3.6 or later.
69+
- Added support for Wave (`.wav`) files.
70+
71+
v0.7.0
72+
''''''
73+
74+
- Mutagen 1.45.0 or later is now required.
75+
- MediaFile can now use file-like objects (instead of just the filesystem, via
76+
filenames).
77+
78+
v0.6.0
79+
''''''
80+
81+
- Enforce a minimum value for SoundCheck gain values.
82+
83+
v0.5.0
84+
''''''
85+
86+
- Refactored the distribution to use `Flit`_.
87+
88+
.. _Flit: https://flit.readthedocs.io/
89+
90+
v0.4.0
91+
''''''
92+
93+
- Added a ``barcode`` field.
94+
- Added new tag mappings for ``albumtype`` and ``albumstatus``.
95+
96+
v0.3.0
97+
''''''
98+
99+
- Fixed tests for compatibility with Mutagen 1.43.
100+
- Fix the MPEG-4 tag mapping for the ``label`` field to use the right
101+
capitalization.
102+
103+
v0.2.0
104+
''''''
105+
106+
- R128 gain tags are now stored in Q7.8 integer format, as per
107+
`the relevant standard`_.
108+
- Added an ``mb_workid`` field.
109+
- The Python source distribution now includes an ``__init__.py`` file that
110+
makes it easier to run the tests.
111+
112+
.. _the relevant standard: https://tools.ietf.org/html/rfc7845.html#page-25
113+
114+
v0.1.0
115+
''''''
116+
117+
This is the first independent release of MediaFile.
118+
It is now synchronised with the embedded version released with `beets`_ v1.4.8.
119+
120+
.. _beets: https://beets.io

0 commit comments

Comments
 (0)