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

add isort in pre-commit #297

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BDadmehr0
Copy link
Contributor

➜  Salam git:(main) ✗ pre-commit run isort --all-files

[WARNING] Unexpected key(s) present on https://github.com/adrienverge/yamllint => yamllint: env
isort (python)...........................................................Passed

@BaseMax
Copy link
Member

BaseMax commented Nov 7, 2024

Please change

import filecmp
import os
from pathlib import Path

to:

import os
import filecmp
from pathlib import Path

@BDadmehr0
Copy link
Contributor Author

Please change

import filecmp
import os
from pathlib import Path

to:

import os
import filecmp
from pathlib import Path

The process is isort, and even if I change this file in the way you suggest, isort will revert it to its previous state unless we exclude this file from being checked by isort.

@BaseMax
Copy link
Member

BaseMax commented Nov 7, 2024

Cool. how? What is the thinking methodology behind this sorting?

Copy link
Member

@BaseMax BaseMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks

@BDadmehr0
Copy link
Contributor Author

Cool. how? What is the thinking methodology behind this sorting?

The reason why isort writes filecmp first and then os is due to alphabetical order. According to isort's standards, all imports must be sorted alphabetically.

@BaseMax
Copy link
Member

BaseMax commented Nov 7, 2024

Okay good, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants