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

Add skip comment to disable add-modules lines on a per-file basis. #1737

Closed
mjpieters opened this issue May 27, 2021 · 1 comment · Fixed by #1749
Closed

Add skip comment to disable add-modules lines on a per-file basis. #1737

mjpieters opened this issue May 27, 2021 · 1 comment · Fixed by #1749
Labels
enhancement New feature or request

Comments

@mjpieters
Copy link
Contributor

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.

@timothycrosley timothycrosley added the enhancement New feature or request label Jun 13, 2021
timothycrosley added a commit that referenced this issue Jun 17, 2021
@timothycrosley
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants