Hatch 1.12.0 ruff defaults invalid for Ruff 0.6.2 (match upstream flake8-trio/flake8-async)
One of the stated benefits of a persistent ruff_defaults.toml generated by hatch fmt --check --sync is that it enables consistency with external tools. However, the defaults generated break when one uses a new version of ruff for IDE integration via LSP.
This is due to some rules in Ruff being changed to match flake8-async and flake8-trio, as mentioned here: https://github.com/astral-sh/ruff/pull/10416
Problems
Errors:
These no longer exist:
❯ ruff check src
ruff failed
Cause: Failed to parse redacted/ruff_defaults.toml
Cause: TOML parse error at line 7, column 1
|
7 | [lint]
| ^^^^^^
Unknown rule selector: `ASYNC101`
And likewise for ASYNC102.
Warnings:
warning: `PLR1701` has been remapped to `SIM101`.
warning: `TRIO100` has been remapped to `ASYNC100`.
warning: `TRIO105` has been remapped to `ASYNC105`.
warning: `TRIO109` has been remapped to `ASYNC109`.
warning: `TRIO110` has been remapped to `ASYNC110`.
warning: `TRIO115` has been remapped to `ASYNC115`.
warning: Rule `E999` is deprecated and will be removed in a future release. Syntax errors will always be shown regardless of whether this rule is selected or not.
warning: Rule `UP027` is deprecated and will be removed in a future release.
Proposed Fix
Update the version of ruff used in Hatch to 0.6.x, and make the changes shown above to the default configuration.
Related
Previous: #1084 See also: #1461 (tangentially related)
It looks like @DimitriPapadopoulos already has a PR ready at #1588 (which is now for 0.6.2).
I'm using hatch 1.14.1 and on a new install when I run hatch fmt --check --sync I'm getting the exact error as described above.
The error about ASYNC101 and ASYNC102?
Also, which exact version of hatch? The latest version is 1.14.0.
These rules have indeed been removed from recent versions of ruff, they're even missing from the documentation. Yet they're still visible in hatch 1.14.0: https://github.com/pypa/hatch/blob/55dd8409fd4f8dde5869003d24b04d43dab192a9/src/hatch/cli/fmt/core.py#L169-L172
However, they have been removed from the master branch: https://github.com/pypa/hatch/blob/64031c1cf5d02d85203f68cb7a4fd5db2aa7a004/src/hatch/cli/fmt/core.py#L169-L170
I'm not sure if/when the changes in the master branch will be released in a new version of hatch. Perhaps you should open a specific issue for that, as this issue has already been closed.
I think that answers my question enough for now. We are managing a custom version of ruff and the config for the time being, but we will keep an eye out. Thank you for responding even though this issue is closed. Cheers.
@mattmcla I have this exact issue as well - how are we supposed to be using this with our external tools? E.g. my lint checks in my IDE? It feels pretty bad that they do not show up as we go because the generated config is invalid. I know I could just use my own.
Resolved the errors now so ruff check works, and my IDE is happy.
This results in hatch being unable to function.
Seems a bit unreasonable to ship your own ruff, but have it unable to be used by editors? My editor uses the ruff installed in my venv 🤔