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

isort-pre commit bug #717

Closed
abhayymishraa opened this issue Feb 2, 2025 · 4 comments · Fixed by #718
Closed

isort-pre commit bug #717

abhayymishraa opened this issue Feb 2, 2025 · 4 comments · Fixed by #718
Assignees

Comments

@abhayymishraa
Copy link
Collaborator

Describe the bug
The isort pre-commit hook keeps modifying the same file (schema/tests/project_test.py) in a loop, causing make pre-commit to fail. Even after running git add and committing, isort continues to make changes, preventing a successful commit.

To Reproduce
Steps to reproduce the behavior:

  1. Run make pre-commit.
  2. isort modifies schema/tests/project_test.py and fails.
  3. Run git add schema/tests/project_test.py to stage the changes.
  4. Run git commit -m "Apply isort fix", and isort modifies the file again, preventing the commit.
  5. The loop repeats, making it impossible to complete the commit.

Expected behavior
After running make pre-commit and staging the changes, isort should not modify the file again on commit. The pre-commit hooks should pass without infinite modification loops.

Are you going to work on fixing this?
yes.

Screenshots
https://github.com/user-attachments/assets/c32f4fea-7955-41da-a4df-d0dab835fb24

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser chrome
  • Version 22

Additional context
The issue seems to be caused by a conflict between isort and ruff, as ruff also handles import sorting. Adding --profile=black to isort args in .pre-commit-config.yaml may resolve the issue.

@abhayymishraa
Copy link
Collaborator Author

abhayymishraa commented Feb 2, 2025

hey @arkid15r I know why is this happening!
This is because of this issue:
Ruff already includes import sorting functionality. Ruff is designed to replace isort.
If we'll just remove isort it will be good to go

@abhayymishraa
Copy link
Collaborator Author

hey @arkid15r could you assign it to me ?

@arkid15r
Copy link
Collaborator

arkid15r commented Feb 2, 2025

hey @arkid15r I know why is this happening! This is because of this issue: Ruff already includes import sorting functionality. Ruff is designed to replace isort. If we'll just remove isort it will be good to go

I didn't verify this bug, you're on your own here :)
Let's take a look at the PR

@arkid15r arkid15r moved this from Backlog to In progress in Project Nest Feb 2, 2025
@abhayymishraa
Copy link
Collaborator Author

Thanks @arkid15r! I’ll go ahead and remove isort as Ruff handles import sorting already. I’ll update the PR and test it again to make sure everything works smoothly

@github-project-automation github-project-automation bot moved this from In progress to Done in Project Nest Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants