-
-
Notifications
You must be signed in to change notification settings - Fork 574
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
Feature request: separate TYPE_CHECKING #1795
Comments
Hi @juanolon, I can see why this would be useful, but unfortunately, while it may seem simple on the outside, it goes well behind what isort could reasonably support. isort only looks at, parses, and understands imports. This would require it to fully understand all syntax elements to even get it right most of the time. Even if it did that, it would still fail plenty of times, where either the import has a side effect that's intentional, or the annotation is meant for runtime (ala fastapi). Sorry! ~Timothy |
ic. thanks anyway! |
@timothycrosley Any chance you could revisit this now that a flake8 plugin suggests putting things under type checking blocks? We would only need to support |
It would be great if you could reconsider implementing this @timothycrosley. I think "require it to fully understand all syntax elements" is a bit overestimated here, because this would just need a single special case for "if TYPE_CHECKING". Please also note that even mypys own detection of this is extremely simple. it doesnt even support import aliases: python/mypy#12928 |
Hello,
I was looking for a option to separate my imports, which are only for type checking from all the others, and wrap them into an if block. I look into the issues and only found this thread: #818 (comment)
It would convert this:
to
That would be huge. Thanks!
The text was updated successfully, but these errors were encountered: