Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ruff's minimum python version #404

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nanonanomachine
Copy link

Rationale

pedalboard supports python version >=3.8 ref.

However Ruff's latest 0.9.10's target-version is 3.9 by default ref . It's good to specify the minimum target version so that we will not have lint/format errors targeting 3.9.

I confirmed recent CI runs with Ruff version 0.9.10 and it seems existing pytest codes have format errors.
https://github.com/spotify/pedalboard/actions/runs/13666616245/job/38209420452?pr=403

Changes

  1. Add --target-version option to ruff format and ruff check commands.
      --target-version <TARGET_VERSION>
          The minimum Python version that should be supported
          
          [possible values: py37, py38, py39, py310, py311, py312, py313]
ruff command help
root@cd4bc9e7aab4:/workspaces/pedalboard# ruff --version
ruff 0.9.10
root@cd4bc9e7aab4:/workspaces/pedalboard# ruff format --help
Run the Ruff formatter on the given files or directories

Usage: ruff format [OPTIONS] [FILES]...

Arguments:
  [FILES]...
          List of files or directories to format [default: .]

Options:
      --check
          Avoid writing any formatted files back; instead, exit with a non-zero status code if any files would have been modified, and zero otherwise

      --diff
          Avoid writing any formatted files back; instead, exit with a non-zero status code and the difference between the current file and how the formatted file would look like

      --extension <EXTENSION>
          List of mappings from file extension to language (one of `python`, `ipynb`, `pyi`). For example, to treat `.ipy` files as IPython notebooks, use `--extension ipy:ipynb`

      --target-version <TARGET_VERSION>
          The minimum Python version that should be supported
          
          [possible values: py37, py38, py39, py310, py311, py312, py313]

      --preview
          Enable preview mode; enables unstable formatting. Use `--no-preview` to disable

  -h, --help
          Print help (see a summary with '-h')

Miscellaneous:
  -n, --no-cache
          Disable cache reads
          
          [env: RUFF_NO_CACHE=]

      --cache-dir <CACHE_DIR>
          Path to the cache directory
          
          [env: RUFF_CACHE_DIR=]

      --stdin-filename <STDIN_FILENAME>
          The name of the file when passing it through stdin

File selection:
      --respect-gitignore
          Respect file exclusions via `.gitignore` and other standard ignore files. Use `--no-respect-gitignore` to disable

      --exclude <FILE_PATTERN>
          List of paths, used to omit files and/or directories from analysis

      --force-exclude
          Enforce exclusions, even for paths passed to Ruff directly on the command-line. Use `--no-force-exclude` to disable

Format configuration:
      --line-length <LINE_LENGTH>
          Set the line-length

Editor options:
      --range <RANGE>
          When specified, Ruff will try to only format the code in the given range.
          It might be necessary to extend the start backwards or the end forwards, to fully enclose a logical line.
          The `<RANGE>` uses the format `<start_line>:<start_column>-<end_line>:<end_column>`.
          
          - The line and column numbers are 1 based.
          - The column specifies the nth-unicode codepoint on that line.
          - The end offset is exclusive.
          - The column numbers are optional. You can write `--range=1-2` instead of `--range=1:1-2:1`.
          - The end position is optional. You can write `--range=2` to format the entire document starting from the second line.
          - The start position is optional. You can write `--range=-3` to format the first three lines of the document.
          
          The option can only be used when formatting a single file. Range formatting of notebooks is unsupported.

Log levels:
  -v, --verbose
          Enable verbose logging

  -q, --quiet
          Print diagnostics, but nothing else

  -s, --silent
          Disable all logging (but still exit with status code "1" upon detecting diagnostics)

Global options:
      --config <CONFIG_OPTION>
          Either a path to a TOML configuration file (`pyproject.toml` or `ruff.toml`), or a TOML `<KEY> = <VALUE>` pair (such as you might find in a `ruff.toml` configuration file) overriding a specific configuration option. Overrides of
          individual settings using this option always take precedence over all configuration files, including configuration files that were also specified using `--config`

      --isolated
          Ignore all configuration files
root@cd4bc9e7aab4:/workspaces/pedalboard# ruff check --help
Run Ruff on the given files or directories

Usage: ruff check [OPTIONS] [FILES]...

Arguments:
  [FILES]...  List of files or directories to check [default: .]

Options:
      --fix                              Apply fixes to resolve lint violations. Use `--no-fix` to disable or `--unsafe-fixes` to include unsafe fixes
      --unsafe-fixes                     Include fixes that may not retain the original intent of the code. Use `--no-unsafe-fixes` to disable
      --show-fixes                       Show an enumeration of all fixed lint violations. Use `--no-show-fixes` to disable
      --diff                             Avoid writing any fixed files back; instead, output a diff for each changed file to stdout, and exit 0 if there are no diffs. Implies `--fix-only`
  -w, --watch                            Run in watch mode by re-running whenever files change
      --fix-only                         Apply fixes to resolve lint violations, but don't report on, or exit non-zero for, leftover violations. Implies `--fix`. Use `--no-fix-only` to disable or `--unsafe-fixes` to include unsafe fixes
      --ignore-noqa                      Ignore any `# noqa` comments
      --output-format <OUTPUT_FORMAT>    Output serialization format for violations. The default serialization format is "full" [env: RUFF_OUTPUT_FORMAT=] [possible values: concise, full, json, json-lines, junit, grouped, github, gitlab, pylint,
                                         rdjson, azure, sarif]
  -o, --output-file <OUTPUT_FILE>        Specify file to write the linter output to (default: stdout) [env: RUFF_OUTPUT_FILE=]
      --target-version <TARGET_VERSION>  The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311, py312, py313]
      --preview                          Enable preview mode; checks will include unstable rules and fixes. Use `--no-preview` to disable
      --extension <EXTENSION>            List of mappings from file extension to language (one of `python`, `ipynb`, `pyi`). For example, to treat `.ipy` files as IPython notebooks, use `--extension ipy:ipynb`
      --statistics                       Show counts for every rule with at least one violation
      --add-noqa                         Enable automatic additions of `noqa` directives to failing lines
      --show-files                       See the files Ruff will be run against with the current settings
      --show-settings                    See the settings Ruff will use to lint a given Python file
  -h, --help                             Print help

Rule selection:
      --select <RULE_CODE>                                 Comma-separated list of rule codes to enable (or ALL, to enable all rules)
      --ignore <RULE_CODE>                                 Comma-separated list of rule codes to disable
      --extend-select <RULE_CODE>                          Like --select, but adds additional rule codes on top of those already specified
      --per-file-ignores <PER_FILE_IGNORES>                List of mappings from file pattern to code to exclude
      --extend-per-file-ignores <EXTEND_PER_FILE_IGNORES>  Like `--per-file-ignores`, but adds additional ignores on top of those already specified
      --fixable <RULE_CODE>                                List of rule codes to treat as eligible for fix. Only applicable when fix itself is enabled (e.g., via `--fix`)
      --unfixable <RULE_CODE>                              List of rule codes to treat as ineligible for fix. Only applicable when fix itself is enabled (e.g., via `--fix`)
      --extend-fixable <RULE_CODE>                         Like --fixable, but adds additional rule codes on top of those already specified

File selection:
      --exclude <FILE_PATTERN>         List of paths, used to omit files and/or directories from analysis
      --extend-exclude <FILE_PATTERN>  Like --exclude, but adds additional files and directories on top of those already excluded
      --respect-gitignore              Respect file exclusions via `.gitignore` and other standard ignore files. Use `--no-respect-gitignore` to disable
      --force-exclude                  Enforce exclusions, even for paths passed to Ruff directly on the command-line. Use `--no-force-exclude` to disable

Miscellaneous:
  -n, --no-cache                         Disable cache reads [env: RUFF_NO_CACHE=]
      --cache-dir <CACHE_DIR>            Path to the cache directory [env: RUFF_CACHE_DIR=]
      --stdin-filename <STDIN_FILENAME>  The name of the file when passing it through stdin
  -e, --exit-zero                        Exit with status code "0", even upon detecting lint violations
      --exit-non-zero-on-fix             Exit with a non-zero status code if any files were modified via fix, even if no lint violations remain

Log levels:
  -v, --verbose  Enable verbose logging
  -q, --quiet    Print diagnostics, but nothing else
  -s, --silent   Disable all logging (but still exit with status code "1" upon detecting diagnostics)

Global options:
      --config <CONFIG_OPTION>  Either a path to a TOML configuration file (`pyproject.toml` or `ruff.toml`), or a TOML `<KEY> = <VALUE>` pair (such as you might find in a `ruff.toml` configuration file) overriding a specific configuration option.
                                Overrides of individual settings using this option always take precedence over all configuration files, including configuration files that were also specified using `--config`
      --isolated                Ignore all configuration files
  1. Fix ruff format errors by adding target-version options.

Refs

Ruff 0.9.10 code related to default python-version:

It seems from 0.8.0, it's changed to use py39 ref
0.8.0 release Nov 22, 2024

@nanonanomachine nanonanomachine changed the title Fix ruff's minimum python version Fix Ruff's minimum python version Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant