PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.49k stars 580 forks source link

Replace Imports #1534

Open timothycrosley opened 4 years ago

timothycrosley commented 4 years ago

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).

piotrgredowski commented 4 years ago

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? :)

timothycrosley commented 4 years ago

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

piotrgredowski commented 4 years ago

@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?

timothycrosley commented 4 years ago

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!