-
Notifications
You must be signed in to change notification settings - Fork 32
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
vim-isort as a static syntax checker #10
Comments
Hi. No progress on this that I know of. I more or less gave up, particularly since most of time is spent on larger projects now where cosmetic changes are frowned upon. |
@krzysztof good point. Don't know if Isort is able to "tell" you which imports are not correctly ordered. @johntyree are you talking about syntastic? |
@fisadev yes sorry. @krzysztof emailed me asking about it and I thought responding in public would be more useful. All we really need is for isort to output the line containing unsorted imports, not which imports are out of order. If we were willing to write a dirty hack we could make use of a temp file and diff, but at that point it's honestly probably easier to just contribute upstream or write some VimL to do it. |
After skimming through the isort code I think it's going to be quite tricky to get just the line numbers, as isort doesn't seem to detect the imports missortings explicitly, but instead proceeds with sorting the import section according to some predefined rules and then compares the result with the original input (hence the natural orientation towards the diff and "apply changes" features). I think that analyzing the diff message could still work although as @johntyree said, it will be quite a dirty job to get it right. |
Patching upstream to support just outputting line numbers or writing something ourselves is probably the only real way to make use of this as a linter. Outputting a diff and doing something with it is going to be really fragile and ugly. |
I have to agree with @johntyree on that, although it seems like it will require substantial effort to implement something like this within isort. The way isort seems to be working is to detect the import blocks, sort them according to predefined rules and generate a diff. The concept of line number is not really there at any point. I have forwarded this issue to @timothycrosley. Parsing a diff is ugly and fragile, but with enough care it should at least produce stable and deterministic output. |
This can be accomplished via https://pypi.org/project/flake8-isort/ |
Has anyone tried to add Isort/vim-isort as a syntax checker to syntastic ?
All I could find was this issue: vim-syntastic/syntastic#895
I would rather be informed of missorts rather than have them sorted automatically after executing the Isort command.
The text was updated successfully, but these errors were encountered: