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

ruff.toml doesn't work with [tool.ruff] hierarchy #4725

Closed
turnerm opened this issue May 30, 2023 · 5 comments · Fixed by #4732
Closed

ruff.toml doesn't work with [tool.ruff] hierarchy #4725

turnerm opened this issue May 30, 2023 · 5 comments · Fixed by #4732
Assignees

Comments

@turnerm
Copy link

turnerm commented May 30, 2023

The ruff documentation states the following:

As an alternative to pyproject.toml, Ruff will also respect a ruff.toml (or .ruff.toml) file, which implements an equivalent schema (though the [tool.ruff] hierarchy can be omitted).

In particular, stating that the [tool.ruff] hierarchy can be omitted implies that it should be possible to use the hierarchy in ruff.toml.

However, I do not find this to be the case. In particular, I've created the following ruff.toml:

[tool.ruff]
line-length = 79

Then with Python 3.11 and ruff 0.0.270 I tried running the command ruff check *, and get the following error:

error: Failed to parse `/home/turnerm/scratch/ruff_test/ruff.toml`: TOML parse error at line 1, column 2
  |
1 | [tool.ruff]
  |  ^^^^
unknown field `tool`, expected one of `allowed-confusables`, `builtins`, `cache-dir`, `dummy-variable-rgx`, `exclude`, `extend`, `extend-exclude`, `extend-include`, `extend-ignore`, `extend-select`, `extend-fixable`, `extend-unfixable`, `external`, `fix`, `fix-only`, `fixable`, `format`, `force-exclude`, `ignore`, `ignore-init-module-imports`, `include`, `line-length`, `tab-size`, `required-version`, `respect-gitignore`, `select`, `show-source`, `show-fixes`, `src`, `namespace-packages`, `target-version`, `task-tags`, `typing-modules`, `unfixable`, `flake8-annotations`, `flake8-bandit`, `flake8-bugbear`, `flake8-builtins`, `flake8-comprehensions`, `flake8-errmsg`, `flake8-quotes`, `flake8-self`, `flake8-tidy-imports`, `flake8-type-checking`, `flake8-gettext`, `flake8-implicit-str-concat`, `flake8-import-conventions`, `flake8-pytest-style`, `flake8-unused-arguments`, `isort`, `mccabe`, `pep8-naming`, `pycodestyle`, `pydocstyle`, `pylint`, `per-file-ignores`, `extend-per-file-ignores`

If I change the name of ruff.toml to pyproject.toml, or remove the [ruff.toml] heading, then ruff runs without error.

@charliermarsh
Copy link
Member

The documentation should be clearer on this point: [tool.ruff] has to be omitted for ruff.toml (it's not optional).

@cartok
Copy link

cartok commented Oct 31, 2023

People will still land here cause the preset is using it. https://github.com/astral-sh/ruff#configuration.

@phillipjohnston
Copy link

People will still land here cause the preset is using it. https://github.com/astral-sh/ruff#configuration.

I did this just now while working through the readme.

@charliermarsh
Copy link
Member

I don't think we can put tabs in the README (unlike in the docs). I'll try to clarify it.

@AlexWaygood
Copy link
Member

AlexWaygood commented Mar 13, 2024

I don't think we can put tabs in the README (unlike in the docs).

Yeah that seems correct :/ github/markup#1552 (comment)

charliermarsh added a commit that referenced this issue Mar 13, 2024
## Summary

See feedback in
#4725 (comment).

In the docs, we use a tabbed interface for express `ruff.toml` vs.
`pyproject.toml`. Here, it might be clearer to default to `ruff.toml`,
since it's more obviously _not_ `pyproject.toml`. But either way, this
PR attempts to clarify that there's a difference.
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 a pull request may close this issue.

5 participants