isort icon indicating copy to clipboard operation
isort copied to clipboard

Replace Imports

Open timothycrosley opened this issue 4 years ago • 4 comments

Currently, isort has functionality to enable adding imports and removing imports. It would be useful to add functionality to replace imports (adding only when removed).

timothycrosley avatar Oct 07 '20 04:10 timothycrosley

Hi @timothycrosley! Do you mean something similar to these functionalities of CLI? https://github.com/PyCQA/isort#adding-an-import-to-multiple-files https://github.com/PyCQA/isort#removing-an-import-from-multiple-files Or do you mean something else? :)

piotrgredowski avatar Oct 07 '20 18:10 piotrgredowski

@piotrgredowski exactly those! The project would be to add a third option to replace imports.

timothycrosley avatar Oct 08 '20 07:10 timothycrosley

@timothycrosley I've started working on that. Can you assign it to me? And have two questions - should it be forbidden to use together:

  1. adding imports with replacing imports,
  2. removing imports with replacing imports?

If user can do both operations in same call - it will be harder to do :smiley: because what should be more important in that case?

piotrgredowski avatar Oct 10 '20 18:10 piotrgredowski

If those constraints make it easier to create the initial implementation, I'm very comfortable with both being put in place. We'd just want to document it and make the error reporting as intuitive as possible.

Thanks!

timothycrosley avatar Oct 11 '20 07:10 timothycrosley