PyCQA / PyCQA/isort

isort gets confused when working with git worktrees

Open
#2,068 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

If I work with git worktrees, isort (in the pre-commit hook) gets confused and identifies first party library code in the worktree as third party library.

I use

- repo: https://github.com/PyCQA/isort
  rev: 5.10.1
  hooks:
    - id: isort
      name: isort

What I do is:

git clone REPOSITORY.git
cd REPOSITORY
git worktree add ../REPOSITORY_WORKTREE BRANCH_WORKTREE
cd ../REPOSITORY_WORKTREE
pre-commit run --all

What it then does from:

import THIRDPARTY

import OWNCODE

when I run pre-commit run --all is:

import OWNCODE
import THIRDPARTY

or

import THIRDPARTY
import OWNCODE

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report using the shown git worktree commands and pre-commit run --all with isort 5.10.1. Trace how isort classifies imports when invoked through the pre-commit hook, then verify that first-party code in the worktree remains separated from third-party imports in both reported outcomes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.