isort will not parse directories anymore, are there variants?

713 views Asked by At

Used isort for a while, but now it starts complaining about the fact that a directory is a directory??

venv/bin/isort --diff --check src tests
WARNING: Unable to parse file src due to [Errno 21] Is a directory: '[...]/src'
WARNING: Unable to parse file tests due to [Errno 21] Is a directory: '[...]/tests'

Are there more than one variants of isort??

1

There are 1 answers

0
ventaquil On

Try to add -rc/--recursive flags.

$ isort --help
...
  -c, --check-only      Checks the file for unsorted / unformatted imports and prints them to the command line without modifying the file.
...
  -df, --diff           Prints a diff of all the changes isort would make to a file, instead of changing it in place
...
  -rc, --recursive      Recursively look for Python files of which to sort imports
...

So in your case the following line should work (--check was replaced with --check-only).

$ venv/bin/isort --check-only --diff --recursive src tests

You can use even shorter form.

$ venv/bin/isort -c -df -rc src tests

Check this comment from GitHub repo.