Closed
Description
I am adding from __future__ import annotations
to our project files, automatically, using isort
. But, in highly specialised cases such as marshmallow-dataclasses
use, I'd like isort to not add that import line.
Right now I can only do so by adding # isort: skip_file
to a module where I don't want the extra import to be added automatically.
Could isort perhaps support the following syntax?
# isort: skip: from __future__ import annotations
This would be treated as a add_imports.remove("from __future__ import annotations")
action, and you'd have to add this comment high enough in the file to apply before add_imports
is processed.
Activity
Implemented #1737: Support for using action comments to avoid adding …
timothycrosley commentedon Jun 17, 2021
Hi @mjpieters,
Thanks for the great feature suggestion! This has been implemented as 2 new action comments, documented here: https://pycqa.github.io/isort/docs/configuration/action_comments.html#isort-dont-add-imports to skip all adding, or the adding of a particular import to a file. This will be released to PyPI later this week.
Thanks!
~Timothy