Skip to content

Commit

Permalink
Merge pull request #256 from abhiashu/remove_unused_imports_made_opti…
Browse files Browse the repository at this point in the history
…onal

Retaining unused imports based on user's choice
  • Loading branch information
lyz-code authored May 10, 2024
2 parents b421368 + 0943c0d commit 18cfe02
Show file tree
Hide file tree
Showing 6 changed files with 937 additions and 659 deletions.
9 changes: 9 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ This can be problematic when run in `__init__.py` files, which often contain
the `--ignore-init-modules` flag, which will filter away any passed
`__init__.py` files before processing.

There may be import statements that are being used dynamically,
to autoimport it would look like those are not being used but actually they may have some usages.

In such cases where you want to retain the unused imports across any file, you can use the `--keep-unused-imports` flag,
which will prevent `autoimport` from removing any import statements.

**Note:** If there are not many cases where you intend to keep the unused imports, prefer placing
`#noqa: autoimport` on the concerned import line/s, over using the `--keep-unused-imports` flag.

## Moving the imports to the top

There are going to be import cases that may not work, if you find one, please
Expand Down
Loading

0 comments on commit 18cfe02

Please sign in to comment.