4 ms·
We're actually working on a heuristic that can signal yapf to break arguments to one per line, and do the same for data structures (think a dict initialization)
by eliben 12y ago
We're actually working on a heuristic that can signal yapf to break arguments to one per line, and do the same for data structures (think a dict initialization).
Ultimately, we'd like to have these things configurable via the style settings of yapf, so multiple detailed styles can be selected.
Patches welcome :)
- zo1 12y agoIf you'd like my suggestion. I've been quite annoyed with some of the "odd" or "non-consistent" ways for splitting long lines onto multiple lines (either on definitions, or plain calls to functions). Eventually, I did come up with a consistent way to do so. Have a look at below: def OtherLongFunctionName(One, Two, Three ): print "Does stuff" def MyFunction(Param1, OtherParam, FooParam, EtcParam ): if ((Param1 * 1000) > 5000 && OtherParam is not None && len(FooParam) > 50 ): new_instance_dict = { "TestingFoo": Param1, "NewFoo": OtherParam, "LongFooBar": FooParam, } recursive = MyFunction( OtherLongFunctionName( Param1, OtherParam, FooParam ) ) It doesn't comply to PEP8 due to the indentation of nested params and stuff on the new lines. PEP8 apparently wants them aligned with the opening/starting bracket. This looks horrible, and just right-aligns all your code into little columns. And doesn't work very well with nested function calls.
- data_scientist 12y agoPlease don't make it configurable, because it will mean there is no longer "a" YAPF standard. Also look at Pycharm reformat tool, it would be a shame if both couldn't be used in the same versionned project.