isort
isort copied to clipboard
Incorrect sorting
isort sorts third-party socketio to local imports.
Before:
import jwt
from socketio.exceptions import ConnectionRefusedError
from src.core.auth import auth_backend
After:
import jwt
from socketio.exceptions import ConnectionRefusedError
from src.core.auth import auth_backend
My guess is that it can be because of the socketio module in the src directory:
├── src
└── socketio
In pre-commit config:
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]
@nyudenkov after and before code snippets looks, exactly same to me. Plz recheck.
Hi @nyudenkov! I was able to reproduce this error like this: File structure
├── check
└── .isort.cfg
└── src
└── socketio
.isort.cfg
[settings]
profile=black
src_paths=src
You are right, it indeed happens because of the local socketio module.
If I change src_paths to src_paths=. then from socketio.exceptions import ConnectionRefusedError is no longer treated as a local import. May it help you with the issue?
@bp72 I'll check, thank you
Hi @nyudenkov! Just wanted to check in and see if you had a chance to take a look. Did it help you out? Let me know if you need any further assistance!