PyCQA / isort

A Python utility / library to sort imports.

Home Page:https://pycqa.github.io/isort/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It seems `--jobs` and `--diff` cannot be used together

ian-h-chamberlain opened this issue · comments

I couldn't find any documention or other issues on this, so I'm not sure if this is intended behavior (and undocumented) or just a bug.

Tested with isort 5.13.2, running isort --diff --jobs=2 acts the same as isort --jobs=2 (that is, the --diff option is ignored). I could imagine there might be a concern about interleaving diff output from different jobs, in which case I think there are a couple options:

  1. Disallow --diff --jobs (and equivalent config) entirely and display an error (and document this behavior)
  2. Implement some kind of locking to serialize the diffs from different jobs
  3. Do nothing to prevent interleaving and hope for the best (maybe document this as a caveat?)

The cause of the current behavior seems pretty clear: show_diff is not plumbed into the executor if jobs is used: https://github.com/PyCQA/isort/blob/main/isort/main.py#L1193-L1223

From a quick test, adding show_diff=show_diff to the executor.imap call seems to work in simple cases (effectively option 3) but I haven't tested it extensively with lots of files at once or high job counts.