Skip to content

Static analysis configuration


Static analysis performed by the fmt command is backed entirely by Ruff.

Hatch provides default settings that user configuration can extend.

Extending config

When defining your configuration, be sure to use options that are prefixed by extend- such as extend-select, for example:

[tool.ruff.lint]
preview = true
extend-select = ["C901"]

[tool.ruff.lint.extend-per-file-ignores]
"docs/.hooks/*" = ["INP001", "T201"]

[tool.ruff.lint.isort]
known-first-party = ["foo", "bar"]

[tool.ruff.format]
preview = true
quote-style = "single"
[lint]
preview = true
extend-select = ["C901"]

[lint.extend-per-file-ignores]
"docs/.hooks/*" = ["INP001", "T201"]

[lint.isort]
known-first-party = ["foo", "bar"]

[format]
preview = true
quote-style = "single"

Note

When not persisting config, there is no need to explicitly extend the defaults as Hatch automatically handles that.

Persistent config

If you want to store the default configuration in the project, set an explicit path like so:

[tool.hatch.format]
config-path = "ruff_defaults.toml"
[format]
config-path = "ruff_defaults.toml"

Then instruct Ruff to consider your configuration as an extension of the default file:

[tool.ruff]
extend = "ruff_defaults.toml"
extend = "ruff_defaults.toml"

Anytime you wish to update the defaults (such as when upgrading Hatch), you must run the fmt command once with the --sync flag e.g.:

hatch fmt --check --sync

Tip

This is the recommended approach since it allows other tools like IDEs to use the default configuration.

Default settings

Non-rule settings

Per-file ignored rules

Selected rules

The following rules are based on version 0.1.7 of Ruff.