-
-
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
Add multi_line_output
mode for more compact formatting
#941
Comments
FYI, the current mode 0 matches the pep8 style guide whereas the suggestion for indent does not. |
While I don't have the bandwith to add support for this requested feature myself, I will accept a pull request that adds it. The correct place to add this functionality is here: https://github.com/timothycrosley/isort/blob/develop/isort/wrap_modes.py#L46 |
Thanks @timothycrosley. I'll try to find time to take a stab at this. Line 36 says that name and order are significant; should I add a new |
@gwk, Glad to hear! Look forward to the pull request. Yes that's correct, right after noqa. Thanks! ~Timothy |
Hi there, I looked into this one a bit and it can be almost achieved with the This problem seems to occur in the other modes as well, but the other way around ie. most of them hard-code the usage of parentheses. I made some modifications in my fork that makes
Please let me know what you think about this approach. If it is OK, I would prefer to look at the tests covering this area and add some additional ones and/or update some to reflect the changes. Thanks, Tamas |
This looks like what I was hoping for. My only question is, does this insert parentheses unconditionally or only when the line needs to wrap? |
Will put more details here later, but, the |
Some additional information: Here is the official release policy: https://timothycrosley.github.io/isort/docs/major_releases/release_policy/#formatting-guarantees Thanks! ~Timothy |
All that makes a lot of sense. What would be a good name for the new wrap mode? As a side note, it might be just me, but the mode names don't really tell me what the difference is between them. Thanks, Tamas |
Hi @gwk It inserts the parentheses just when the lines wraps. Thanks, Tamas |
Open to any name that makes sense, your initial observations make me think
Yes that's correct! If that assumption isn't commented in the source file via comments and/or via tests, another improvement that could be made is clarifying it.
💯 % This. It would be really nice to have autogenerated docs, under the config tab of the new documentation website. Maybe pick a long example multi import statement and auto run it through all modes. Again this is just a bonus improvement that could be done. Thanks for all the thought put into this! ~Timothy |
I like
We have the numeric short-hands OFC, maybe worth introducing short-hands based on the first character of the modes that have more than 1 word? Would be similar to what you have for normal options already, backward compatible and there are no conflicts ATM:
That's another idea that can result in another issue/PR though 😄 , going back to this issue there is still one related problem left. Am I fixing it while I'm at it or would you prefer that to be separated into another separate issue? Thanks, Tamas |
Adds a new wrap mode Hanging Indent, With Parentheses (10). Fixes PyCQA#941.
OK, I think this is done in the PR linked above. Usage:
I think |
This was just deployed with version 5.2.0 of isort (thanks @sztamas!). ~Timothy |
@sztamas & @timothycrosley, I just want to say thank you for implementing this. I finally got back to working on my library and this did the trick! |
Could we add a mode similar to 0/grid mode, but that uses the fixed indent width for subsequent lines? Mode 0 looks like this:
I would like this (where
indent=2
):This would be more compact, and can reduce line count. I would be happy to attempt a PR; pointers on where to look would be welcome.
isort
has been a great improvement to my workflow; thank you for building it!The text was updated successfully, but these errors were encountered: