Skip to content

ruff_format

ruff documentation

footman._stubs.ruff_format.RuffFormat

Bases: Tool

__call__

__call__(
    *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.

...