Add flynt to the "format" session

`flynt` converts old-style string formatting
into f-strings before `black` formats the result
This commit is contained in:
Alexander Hess 2026-11-28 04:49:05 +01:00
commit 707b4ab652
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -2,8 +2,8 @@
By default, `uv run nox` runs the sessions that assure code quality:
- "format": Format the source files with `autoflake`, `black`, `isort`, and `ruff`
- "lint": Lint the source files with `flake8`, `isort`, and `ruff`
- "format": Format source files with `autoflake`, `black`, `flynt`, `isort`, and `ruff`
- "lint": Lint source files with `flake8`, `isort`, and `ruff`
- "test": Run the test suite with `pytest`
- "doctest": Check if code snippets in the docstrings run
@ -141,7 +141,7 @@ os.makedirs(tempfile.tempdir, exist_ok=True)
@nox.session(name="format", python=MAIN_PYTHON)
def format_code(session: Session) -> None:
"""Format source files with `autoflake`, `black`, `isort`, and `ruff`.
"""Format source files with `autoflake`, `black`, `flynt`, `isort`, and `ruff`.
If no extra arguments are provided, all source files are formatted.
Otherwise, they are interpreted as paths the formatters work on recursively.
@ -150,7 +150,7 @@ def format_code(session: Session) -> None:
# The formatters do not need `velofy` installed
# because they work on the source files directly
install_pinned(session, "autoflake", "black", "isort", "ruff")
install_pinned(session, "autoflake", "black", "flynt", "isort", "ruff")
# Interpret extra arguments as `locations` of source files
locations = session.posargs or SRC_LOCATIONS
@ -160,6 +160,9 @@ def format_code(session: Session) -> None:
session.run("autoflake", "--version")
session.run("autoflake", *locations)
session.run("flynt", "--version")
session.run("flynt", *locations)
session.run("black", "--version")
session.run("black", *locations)