Skip to content

Address ruff formatting issues for local development #2051

Description

@KatieB5

Why are we doing this?

When on the dependabot rota, I reviewed a PR for a version bump for Ruff from 0.16.3 to 0.16.4.

This was a patch release that passed our CI checks, was merged, and deployed successfully. However, after pulling down the branch and running just fix locally (which runs the Ruff linter), I found that Ruff reported two remaining errors:

$ just fix
/home/katie/bin/just _compile requirements.prod.in requirements.prod.txt 
/home/katie/bin/just _compile requirements.dev.in requirements.dev.txt 
$BIN/ruff check --fix .
RUF015 Prefer `next(iter(section.keys()))` over single element slice
  --> hooks/ehrql_branch.py:22:12
   |
20 |         (i, section)
21 |         for i, section in enumerate(config["nav"])
22 |         if list(section.keys())[0] == "ehrQL"
   |            ^^^^^^^^^^^^^^^^^^^^^^^
23 |     )
24 |     new_import_string = ehrql_nav_section["ehrQL"].replace(
   |
help: Replace with `next(iter(section.keys()))`

INP001 File `scripts/wordcount.py` is part of an implicit namespace package. Add an `__init__.py`.
--> scripts/wordcount.py:1:1

Found 4 errors (2 fixed, 2 remaining).
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
error: recipe `fix` failed on line 123 with exit code 1

What are we doing

Resolve the Ruff lint failures introduced by the ruff upgrade.

How will we know when it's done?

just fix completes successfully with no remaining Ruff errors, and the existing CI checks continue to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions