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
3 changed files with 19 additions and 4 deletions

View file

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

View file

@ -86,6 +86,7 @@ dev = [
# Code Formatters # Code Formatters
"autoflake (>=2.4.0,<3.0.0)", "autoflake (>=2.4.0,<3.0.0)",
"black (>=25.12.0,<26.0.0)", "black (>=25.12.0,<26.0.0)",
"flynt (>=1.0.6,<2.0.0)",
"isort (>=9.0.2,<10.0.0)", "isort (>=9.0.2,<10.0.0)",
# Code Analyzers # Code Analyzers

11
uv.lock generated
View file

@ -1076,6 +1076,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b3/0b/1d658aca231a3e4b3c0b9e7fed71ced551cbfd955a41cfd32b221b396edc/flake8_unused_arguments-0.0.14-py3-none-any.whl", hash = "sha256:6c0b7ce7236a156f4bd90adec67ad0e5d0139efcd15c2a1fc0fb3a6ffd7e435e", size = 6190, upload-time = "2025-10-27T22:22:54.888Z" }, { url = "https://files.pythonhosted.org/packages/b3/0b/1d658aca231a3e4b3c0b9e7fed71ced551cbfd955a41cfd32b221b396edc/flake8_unused_arguments-0.0.14-py3-none-any.whl", hash = "sha256:6c0b7ce7236a156f4bd90adec67ad0e5d0139efcd15c2a1fc0fb3a6ffd7e435e", size = 6190, upload-time = "2025-10-27T22:22:54.888Z" },
] ]
[[package]]
name = "flynt"
version = "1.0.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/23/ea/be0bd620182b18af37cc784c6f0e1766246982084776702cd1b5649b6885/flynt-1.0.6.tar.gz", hash = "sha256:471b7ff00756678e2912d4261dcbcd8fc1395129b66bf6977f88a3b3ad220c90", size = 25907, upload-time = "2025-07-29T06:12:46.808Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d7/80/14dc476cf6b6897a613f242beda253ba380f0e25d6355cb299e6b95f2aee/flynt-1.0.6-py3-none-any.whl", hash = "sha256:4e837c9597036b634a347855a89acf1483c4f8b73daa82c49372b10b6e1d1778", size = 36663, upload-time = "2025-07-29T06:12:45.386Z" },
]
[[package]] [[package]]
name = "folium" name = "folium"
version = "1.0.0" version = "1.0.0"
@ -3784,6 +3793,7 @@ dev = [
{ name = "flake8-sfs" }, { name = "flake8-sfs" },
{ name = "flake8-todos" }, { name = "flake8-todos" },
{ name = "flake8-unused-arguments" }, { name = "flake8-unused-arguments" },
{ name = "flynt" },
{ name = "isort" }, { name = "isort" },
{ name = "mypy" }, { name = "mypy" },
{ name = "nox" }, { name = "nox" },
@ -3849,6 +3859,7 @@ dev = [
{ name = "flake8-sfs", specifier = ">=1.0.1,<2.0.0" }, { name = "flake8-sfs", specifier = ">=1.0.1,<2.0.0" },
{ name = "flake8-todos", specifier = ">=0.3.1,<0.4.0" }, { name = "flake8-todos", specifier = ">=0.3.1,<0.4.0" },
{ name = "flake8-unused-arguments", specifier = ">=0.0.14,<0.1.0" }, { name = "flake8-unused-arguments", specifier = ">=0.0.14,<0.1.0" },
{ name = "flynt", specifier = ">=1.0.6,<2.0.0" },
{ name = "isort", specifier = ">=9.0.2,<10.0.0" }, { name = "isort", specifier = ">=9.0.2,<10.0.0" },
{ name = "mypy", specifier = ">=2.4.1,<3.0.0" }, { name = "mypy", specifier = ">=2.4.1,<3.0.0" },
{ name = "nox", specifier = ">=2026.10.20" }, { name = "nox", specifier = ">=2026.10.20" },