Skip to content

ruff

ruff documentation

footman._stubs.ruff.Ruff

Bases: Tool

__call__

__call__(
    *args: str,
    color: Literal["auto", "always", "never"]
    | Sequence[Literal["auto", "always", "never"]]
    | None = ...,
    config: _Value = ...,
    isolated: _Flag = ...,
    quiet: _Flag = ...,
    silent: _Flag = ...,
    verbose: _Flag = ...,
    **flags: Any,
) -> Result

Ruff: An extremely fast Python linter and code formatter.

Parameters:

Name Type Description Default
color Literal['auto', 'always', 'never'] | Sequence[Literal['auto', 'always', 'never']] | None

Control when colored output is used.

...
config _Value

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 (e.g., --config "lint.line-length = 100" or --config "format.quote-style = 'single'").

...
isolated _Flag

Ignore all configuration files.

...
quiet _Flag

Print diagnostics, but nothing else.

...
silent _Flag

Disable all logging (but still exit with status code "1" upon detecting diagnostics).

...
verbose _Flag

Enable verbose logging.

...

check

check(
    *args: str,
    add_ignore: _ValuedFlag = ...,
    add_noqa: _ValuedFlag = ...,
    cache_dir: _Value = ...,
    color: Literal["auto", "always", "never"]
    | Sequence[Literal["auto", "always", "never"]]
    | None = ...,
    config: _Value = ...,
    diff: _Flag = ...,
    exclude: _Value = ...,
    exit_non_zero_on_fix: _Flag = ...,
    exit_zero: _Flag = ...,
    extend_exclude: _Value = ...,
    extend_fixable: _Value = ...,
    extend_per_file_ignores: _Value = ...,
    extend_select: _Value = ...,
    extension: _Value = ...,
    fix: _Flag = ...,
    fix_only: _Flag = ...,
    fixable: _Value = ...,
    force_exclude: _Flag = ...,
    ignore: _Value = ...,
    ignore_noqa: _Flag = ...,
    isolated: _Flag = ...,
    no_cache: _Flag = ...,
    output_file: _Value = ...,
    output_format: Literal[
        "concise",
        "full",
        "json",
        "json-lines",
        "junit",
        "grouped",
        "github",
        "gitlab",
        "pylint",
        "rdjson",
        "azure",
        "sarif",
    ]
    | Sequence[
        Literal[
            "concise",
            "full",
            "json",
            "json-lines",
            "junit",
            "grouped",
            "github",
            "gitlab",
            "pylint",
            "rdjson",
            "azure",
            "sarif",
        ]
    ]
    | None = ...,
    per_file_ignores: _Value = ...,
    preview: _Flag = ...,
    quiet: _Flag = ...,
    respect_gitignore: _Flag = ...,
    select: _Value = ...,
    show_files: _Flag = ...,
    show_fixes: _Flag = ...,
    show_settings: _Flag = ...,
    silent: _Flag = ...,
    statistics: _Flag = ...,
    stdin_filename: _Value = ...,
    target_version: Literal[
        "py37",
        "py38",
        "py39",
        "py310",
        "py311",
        "py312",
        "py313",
        "py314",
        "py315",
    ]
    | Sequence[
        Literal[
            "py37",
            "py38",
            "py39",
            "py310",
            "py311",
            "py312",
            "py313",
            "py314",
            "py315",
        ]
    ]
    | None = ...,
    unfixable: _Value = ...,
    unsafe_fixes: _Flag = ...,
    verbose: _Flag = ...,
    watch: _Flag = ...,
    **flags: Any,
) -> Result

Run Ruff on the given files or directories

Parameters:

Name Type Description Default
add_ignore _ValuedFlag

Enable automatic additions of ruff: ignore comments to failing lines. Value optional: True for the bare flag, or pass one.

...
add_noqa _ValuedFlag

Enable automatic additions of noqa directives to failing lines. Value optional: True for the bare flag, or pass one.

...
cache_dir _Value

Path to the cache directory.

...
color Literal['auto', 'always', 'never'] | Sequence[Literal['auto', 'always', 'never']] | None

Control when colored output is used.

...
config _Value

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 (e.g., --config "lint.line-length = 100" or --config "format.quote-style = 'single'").

...
diff _Flag

Avoid writing any fixed files back; instead, output a diff for each changed file to stdout, and exit 0 if there are no diffs.

...
exclude _Value

List of paths, used to omit files and/or directories from analysis.

...
exit_non_zero_on_fix _Flag

Exit with a non-zero status code if any files were modified via fix, even if no lint violations remain.

...
exit_zero _Flag

Exit with status code "0", even upon detecting lint violations.

...
extend_exclude _Value

Like --exclude, but adds additional files and directories on top of those already excluded.

...
extend_fixable _Value

Like --fixable, but adds additional rule codes on top of those already specified.

...
extend_per_file_ignores _Value

Like --per-file-ignores, but adds additional ignores on top of those already specified.

...
extend_select _Value

Like --select, but adds additional rule codes on top of those already specified.

...
extension _Value

List of mappings from file extension to language (one of python, ipynb, pyi).

...
fix _Flag

Apply fixes to resolve lint violations. fix=off emits --no-fix.

...
fix_only _Flag

Apply fixes to resolve lint violations, but don't report on, or exit non-zero for, leftover violations. fix_only=off emits --no-fix-only.

...
fixable _Value

List of rule codes to treat as eligible for fix.

...
force_exclude _Flag

Enforce exclusions, even for paths passed to Ruff directly on the command-line. force_exclude=off emits --no-force-exclude.

...
ignore _Value

Comma-separated list of rule codes to disable.

...
ignore_noqa _Flag

Ignore any # noqa comments.

...
isolated _Flag

Ignore all configuration files.

...
no_cache _Flag

Disable cache reads.

...
output_file _Value

Specify file to write the linter output to. Defaults to stdout.

...
output_format Literal['concise', 'full', 'json', 'json-lines', 'junit', 'grouped', 'github', 'gitlab', 'pylint', 'rdjson', 'azure', 'sarif'] | Sequence[Literal['concise', 'full', 'json', 'json-lines', 'junit', 'grouped', 'github', 'gitlab', 'pylint', 'rdjson', 'azure', 'sarif']] | None

Output serialization format for violations.

...
per_file_ignores _Value

List of mappings from file pattern to code to exclude.

...
preview _Flag

Enable preview mode; checks will include unstable rules and fixes. preview=off emits --no-preview.

...
quiet _Flag

Print diagnostics, but nothing else.

...
respect_gitignore _Flag

Respect file exclusions via .gitignore and other standard ignore files. respect_gitignore=off emits --no-respect-gitignore.

...
select _Value

Comma-separated list of rule codes to enable (or ALL, to enable all rules).

...
show_files _Flag

See the files Ruff will be run against with the current settings.

...
show_fixes _Flag

Show an enumeration of all fixed lint violations. show_fixes=off emits --no-show-fixes.

...
show_settings _Flag

See the settings Ruff will use to lint a given Python file.

...
silent _Flag

Disable all logging (but still exit with status code "1" upon detecting diagnostics).

...
statistics _Flag

Show counts for every rule with at least one violation.

...
stdin_filename _Value

The name of the file when passing it through stdin.

...
target_version Literal['py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314', 'py315'] | Sequence[Literal['py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314', 'py315']] | None

The minimum Python version that should be supported.

...
unfixable _Value

List of rule codes to treat as ineligible for fix.

...
unsafe_fixes _Flag

Include fixes that may not retain the original intent of the code. unsafe_fixes=off emits --no-unsafe-fixes.

...
verbose _Flag

Enable verbose logging.

...
watch _Flag

Run in watch mode by re-running whenever files change.

...

clean

clean(
    *,
    color: Literal["auto", "always", "never"]
    | Sequence[Literal["auto", "always", "never"]]
    | None = ...,
    config: _Value = ...,
    isolated: _Flag = ...,
    quiet: _Flag = ...,
    silent: _Flag = ...,
    verbose: _Flag = ...,
    **flags: Any,
) -> Result

Clear any caches in the current directory and any subdirectories

Parameters:

Name Type Description Default
color Literal['auto', 'always', 'never'] | Sequence[Literal['auto', 'always', 'never']] | None

Control when colored output is used.

...
config _Value

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 (e.g., --config "lint.line-length = 100" or --config "format.quote-style = 'single'").

...
isolated _Flag

Ignore all configuration files.

...
quiet _Flag

Print diagnostics, but nothing else.

...
silent _Flag

Disable all logging (but still exit with status code "1" upon detecting diagnostics).

...
verbose _Flag

Enable verbose logging.

...

flags

flags(
    *,
    color: Literal["auto", "always", "never"]
    | Sequence[Literal["auto", "always", "never"]]
    | None = ...,
    config: _Value = ...,
    isolated: _Flag = ...,
    quiet: _Flag = ...,
    silent: _Flag = ...,
    verbose: _Flag = ...,
    **flags: Any,
) -> Ruff

Bind tool-level global options before the subcommand.

tools.docker.flags(host=...) puts a tool's own options ahead of the verb, where they belong.

format

format(
    *args: str,
    cache_dir: _Value = ...,
    check: _Flag = ...,
    color: Literal["auto", "always", "never"]
    | Sequence[Literal["auto", "always", "never"]]
    | None = ...,
    config: _Value = ...,
    diff: _Flag = ...,
    exclude: _Value = ...,
    exit_non_zero_on_format: _Flag = ...,
    extend_exclude: _Value = ...,
    extension: _Value = ...,
    force_exclude: _Flag = ...,
    isolated: _Flag = ...,
    line_length: _Value = ...,
    no_cache: _Flag = ...,
    output_format: Literal[
        "concise",
        "full",
        "json",
        "json-lines",
        "junit",
        "grouped",
        "github",
        "gitlab",
        "pylint",
        "rdjson",
        "azure",
        "sarif",
    ]
    | Sequence[
        Literal[
            "concise",
            "full",
            "json",
            "json-lines",
            "junit",
            "grouped",
            "github",
            "gitlab",
            "pylint",
            "rdjson",
            "azure",
            "sarif",
        ]
    ]
    | None = ...,
    preview: _Flag = ...,
    quiet: _Flag = ...,
    range: _Value = ...,
    respect_gitignore: _Flag = ...,
    silent: _Flag = ...,
    stdin_filename: _Value = ...,
    target_version: Literal[
        "py37",
        "py38",
        "py39",
        "py310",
        "py311",
        "py312",
        "py313",
        "py314",
        "py315",
    ]
    | Sequence[
        Literal[
            "py37",
            "py38",
            "py39",
            "py310",
            "py311",
            "py312",
            "py313",
            "py314",
            "py315",
        ]
    ]
    | None = ...,
    verbose: _Flag = ...,
    **flags: Any,
) -> Result

Run the Ruff formatter on the given files or directories

Parameters:

Name Type Description Default
cache_dir _Value

Path to the cache directory.

...
check _Flag

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

...
color Literal['auto', 'always', 'never'] | Sequence[Literal['auto', 'always', 'never']] | None

Control when colored output is used.

...
config _Value

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 (e.g., --config "lint.line-length = 100" or --config "format.quote-style = 'single'").

...
diff _Flag

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.

...
exclude _Value

List of paths, used to omit files and/or directories from analysis.

...
exit_non_zero_on_format _Flag

Exit with a non-zero status code if any files were modified via format, even if all files were formatted successfully.

...
extend_exclude _Value

Like --exclude, but adds additional files and directories on top of those already excluded.

...
extension _Value

List of mappings from file extension to language (one of python, ipynb, pyi).

...
force_exclude _Flag

Enforce exclusions, even for paths passed to Ruff directly on the command-line. force_exclude=off emits --no-force-exclude.

...
isolated _Flag

Ignore all configuration files.

...
line_length _Value

Set the line-length.

...
no_cache _Flag

Disable cache reads.

...
output_format Literal['concise', 'full', 'json', 'json-lines', 'junit', 'grouped', 'github', 'gitlab', 'pylint', 'rdjson', 'azure', 'sarif'] | Sequence[Literal['concise', 'full', 'json', 'json-lines', 'junit', 'grouped', 'github', 'gitlab', 'pylint', 'rdjson', 'azure', 'sarif']] | None

Output serialization format for violations, when used with --check.

...
preview _Flag

Enable preview mode; enables unstable formatting. preview=off emits --no-preview.

...
quiet _Flag

Print diagnostics, but nothing else.

...
range _Value

When specified, Ruff will try to only format the code in the given range.

...
respect_gitignore _Flag

Respect file exclusions via .gitignore and other standard ignore files. respect_gitignore=off emits --no-respect-gitignore.

...
silent _Flag

Disable all logging (but still exit with status code "1" upon detecting diagnostics).

...
stdin_filename _Value

The name of the file when passing it through stdin.

...
target_version Literal['py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314', 'py315'] | Sequence[Literal['py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314', 'py315']] | None

The minimum Python version that should be supported.

...
verbose _Flag

Enable verbose logging.

...