srusskih / SublimeJEDI

awesome Python autocompletion with SublimeText
MIT License
938 stars 109 forks source link

Function arguments - one per line #264

Closed Rastko-V-P closed 6 years ago

Rastko-V-P commented 6 years ago

Wonderful plugin, I enjoy it a lot. Could you introduce an option to autocomplete function arguments one per line? Example:

turn this -> enumerate(iterable, start=0)
into      -> enumerate(iterable,
                        start=0)

This would be particularly useful for functions with a long signature such as pd.read_csv() in combination with "auto_complete_function_params": "all".

srusskih commented 6 years ago

@Rastko-V-P sounds interesting! Thanks for feedback!

edelvalle commented 6 years ago

I personally don't like that style of indentation for parameters because is fragile to break during refactoring. if you have

variable = a_function(bla1,
                      bla2)

and you have to rename variable or a_function you have to fix the indentation of the parameters one by one, and there could be a few of them.

Uncle Bob (Rob Martin) advises to use this way instead:

variable = a_function(
    bla1,
    bla2,
)

Adding trailing commas also, so in case you have to remove or add a parameter only one line is modified.

Rastko-V-P commented 6 years ago

@edalvalle Yes, that's a popular alternative, both formatting styles could be offered as an option. I still prefer the first style because it improves readability and saves 2 lines. Indentation of all parameters can be done in a single go in Sublime.

srusskih commented 6 years ago

@Rastko-V-P have you tried some auto-formatting tools for python? (: like this - https://github.com/csurfer/sublime_black

Rastko-V-P commented 6 years ago

Good point, solved it with PyYapf, thanks for the tip.

srusskih commented 6 years ago

always welcome!