Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment marker to tell ImportOrganizer to keep unused imports #368

Open
1 task
lieryan opened this issue Sep 7, 2021 · 0 comments
Open
1 task

Comment marker to tell ImportOrganizer to keep unused imports #368

lieryan opened this issue Sep 7, 2021 · 0 comments

Comments

@lieryan
Copy link
Member

lieryan commented Sep 7, 2021

Background: #21

The signals import was removed because it wasn't used. I don't want it to be removed though, as the import has intentional side effects.

Removing unused import is an intentional behavior. rope can't know that you intend to use an import just for its side effect. ... It would also be reasonable if user can add a special comment markers (e.g. # rope: keep-unused-import) on imports lines to prevent rope from removing them during reorganization.

An example of what this might look like:

from mod_two import func_three   # rope: keep-unused-import 

or for multiline imports (alternative 1 - special comment only takes effect at the end):

from mod_one import (
    func_one,
    func_two,
)   # rope: keep-unused-import

Or maybe we should do instead (alternative 2 - put it at the first line instead):

from mod_one import (  # rope: keep-unused-import
    func_one,
    func_two,
)   

Additional acceptance criteria:

  • documentation
@lieryan lieryan changed the title Comment marker to tell OrganizeImport to keep unused imports Comment marker to tell ImportOrganizer to keep unused imports Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant