question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function argument splitting differently, given default args

See original GitHub issue

Given:

def long_function_name(var_one, var_two, var_three, var_four, var_five, var_six):
    print(var_one)

yapf --style=pep8 -d longfunc.py returns:

--- longfunc.py (original)
+++ longfunc.py (reformatted)
@@ -1,2 +1,3 @@
-def long_function_name(var_one, var_two, var_three, var_four, var_five, var_six):
+def long_function_name(var_one, var_two, var_three, var_four, var_five,
+                       var_six):
     print(var_one)

But when there is at least one default argument:

def long_function_name(var_one, var_two, var_three, var_four, var_five, var_six=1):
    print(var_one)

yapf --style=pep8 -d longfunc.py returns:

--- longfunc.py (original)
+++ longfunc.py (reformatted)
@@ -1,2 +1,7 @@
-def long_function_name(var_one, var_two, var_three, var_four, var_five, var_six=1):
+def long_function_name(var_one,
+                       var_two,
+                       var_three,
+                       var_four,
+                       var_five,
+                       var_six=1):
     print(var_one)

Is this as intended? Is there currently any way to force argument splitting to always work as in the first example?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jpupucommented, Sep 22, 2016

Setting SPLIT_BEFORE_NAMED_ASSIGNS=False will format the second example similarly to the first:

--- foo.py  (original)
+++ foo.py  (reformatted)
@@ -1,5 +1,8 @@
-def long_function_name(var_one, var_two, var_three, var_four, var_five, var_six):
+def long_function_name(var_one, var_two, var_three, var_four, var_five,
+                       var_six):
     print(var_one)

-def long_function_name(var_one, var_two, var_three, var_four, var_five, var_six=1):
+
+def long_function_name(var_one, var_two, var_three, var_four, var_five,
+                       var_six=1):
     print(var_one)
0reactions
bwendlingcommented, Sep 23, 2016

Thank you. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Split up `...` arguments and distribute to multiple functions
An alternative approach is to provide default values for all noncommon arguments. In general, trying to send the ellipsis args to more than...
Read more >
Python .split() – Splitting a String in Python - freeCodeCamp
split () method accepts, then by default, it will split the string every time it encounters whitespace until the string comes to an...
Read more >
Function to facilitate the control of arguments passed to... - R
Many R functions need to pass several arguments to several different subroutines. ... SmartControl(call, keys, ignore, defaults, forced, split, ignore.case ...
Read more >
Understanding Default Parameters in JavaScript - DigitalOcean
In this article, you will review the difference between parameters and arguments, learn how to use default parameters in functions, see ...
Read more >
Default Arguments in C++ - GeeksforGeeks
A default argument is a value provided in a function declaration that is automatically assigned by the compiler if the calling function ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found