Skip to content

Add Ruff code formatter #19

Description

@CapnKernel

I propose adopting a code linter/formatter. I've been using ruff, a super-fast formatter compatible with the popular Black formatter. It's available as an extension within VSCode.

I'd go ahead and do this, except it's going to make changes to many several files, and this may make merges difficult for us.

I also think we should both run it, otherwise there'll be an endless cycle of small (merge-breaking) commits to the codebase.

I suggest we have these settings in a pyproject.toml file:

[tool.ruff]
line-length = 120

[tool.ruff.format]
# Don't alter existing quote style (should be ' for internal, " for user facing)
quote-style = "preserve"

Reasoning:

  • These days sticking to 80 cols just isn't needed.
  • The coding I've done so far uses the convention that single quotes are used for internal use strings, for example, dictionary keys, and double quotes are used for strings that will go to the user in short order, for example, error messages. The latter means English words like can't don't require escaping.

If you agree to this, let me know a moment when you don't have much unstaged/uncommited/unpushed work, and I'll turn it on.

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