-
-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,858 additions
and
1,240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Static analysis configuration | ||
|
||
----- | ||
|
||
Static analysis performed by the [`fmt`](../cli/reference.md#hatch-fmt) command is backed entirely by [Ruff](https://github.com/astral-sh/ruff). | ||
|
||
Hatch provides default settings that user configuration can [extend](#extending-config). | ||
|
||
## Extending config | ||
|
||
When defining your configuration, be sure to use options that are prefixed by `extend-` such as [`extend-select`](https://docs.astral.sh/ruff/settings/#extend-select), for example: | ||
|
||
=== ":octicons-file-code-16: pyproject.toml" | ||
|
||
```toml | ||
[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" | ||
``` | ||
|
||
=== ":octicons-file-code-16: ruff.toml" | ||
|
||
```toml | ||
[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](#persistent-config), there is no need to explicitly [extend](https://docs.astral.sh/ruff/settings/#extend) the defaults as Hatch automatically handles that internally. | ||
|
||
## Persistent config | ||
|
||
If you want to store the default configuration in the project, set an explicit path like so: | ||
|
||
```toml config-example | ||
[tool.hatch.format] | ||
config-path = "ruff_defaults.toml" | ||
``` | ||
|
||
Then instruct Ruff to consider your configuration as an extension of the default file: | ||
|
||
=== ":octicons-file-code-16: pyproject.toml" | ||
|
||
```toml | ||
[tool.ruff] | ||
extend = "ruff_defaults.toml" | ||
``` | ||
|
||
=== ":octicons-file-code-16: ruff.toml" | ||
|
||
```toml | ||
extend = "ruff_defaults.toml" | ||
``` | ||
|
||
Anytime you wish to update the defaults (such as when upgrading Hatch), you must run the [`fmt`](../cli/reference.md#hatch-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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.