-
Notifications
You must be signed in to change notification settings - Fork 44
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
import sorting? #64
Comments
I have noticed this behavior. If you try to commit the file, I believe I imagine this is due to the: |
This feels like #54 perhaps? Some people have said that clearing the pre-commit cache helps with this: #54 (comment) |
Some combination of these did fix it, though I'm having trouble reproducing the state I was in to confirm exactly what fixed it: .PHONY: pre-commit/remove-cache
pre-commit/remove-cache: ## Remove all of pre-commit's cache
rm -rf ~/.cache/pre-commit/
.PHONY: pre-commit/gc
pre-commit/gc: ## Clean unused cached repos.
@pre-commit gc
.PHONY: pre-commit/autoupdate
pre-commit/autoupdate: ## Update pre-commit hook versions
@pre-commit autoupdate
.PHONY: pre-commit/uninstall
pre-commit/uninstall: ## Uninstall pre-commit
@pre-commit uninstall
.PHONY: pre-commit/install
pre-commit/install: ## Install pre-commit
@pre-commit install --hook-type commit-msg --hook-type pre-push --hook-type pre-commit |
@ringohoffman I have the same problem |
Same problem |
I had this problem until I added - repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.5
hooks:
# Run the linter.
- id: ruff
description: "Run 'ruff' for extremely fast Python linting"
entry: ruff check --force-exclude
language: python
types_or: [ python, pyi, jupyter ]
args: [ --fix, --select, I]
require_serial: true
minimum_pre_commit_version: "2.9.2"
I'm not using a |
Same problem, the two solutions listed in the problem were tried, but the problem was not solved. |
I want to add my two cents to this. As I have described in astral-sh/ruff#8926 (comment) I was having a similar issue where Ruff supposedly wasn't used correctly in the pre-commit-hook. Turns out, I just didn't commit my |
You can list repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.1
hooks:
- id: ruff
name: lint with ruff
- id: ruff
name: sort imports with ruff
args: [--select, I, --fix]
- id: ruff-format
name: format with ruff Unlike when using |
When I use this
pyproject.toml
config:And this
.pre-commit-config.yaml
:On code like this:
The
ruff
hook passes even though the imports aren't sorted:But if I run
ruff check --fix
manually it does fix the imports:Am I missing some other configuration to get import sorting via the
ruff
pre-commit
hook usingargs: [ --fix ]
?The text was updated successfully, but these errors were encountered: