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.

Splitting function arguments into new lines when column limit not reached

See original GitHub issue

Turned this:

 def main():
     p = ArgumentParser(add_help=False)
-    p.add_argument('--config', default=CONFIG,
-                       help='Filename of config file (default %(default)s).')
-    p.add_argument('--interval', type=int, default=INTERVAL,
-                                  help='Cycle time for script (default %(default)d).')
-    p.add_argument('--offset', type=int, default=OFFSET,
-                       help='Delay time for script cycle (default %(default)d).')
-    p.add_argument('--connect-string', default=CONNECT_STRING,
-                       help='Database connect string (%(default)s).')
-    p.add_argument('--proc', default=PROC,
-                       help='SQL Procedure  (%(default)s)')

into:

+    p.add_argument('--config',
+                   default=CONFIG,
+                   help='Filename of config file (default %(default)s).')
+    p.add_argument('--interval',
+                   type=int,
+                   default=INTERVAL,
+                   help='Cycle time for script (default %(default)d).')
+    p.add_argument(
+        '--offset',
+        type=int,
+        default=OFFSET,
+        help='Delay time for script cycle (default %(default)d).')
+    p.add_argument('--connect-string',
+                   default=STRING,
+                   help='Database connect string (%(default)s).')
+    p.add_argument('-proc',
+                   default=PROC,
+                   help='SQL Procedure  (%(default)s)')

My query/problem here is: why have some of the arguments been split off into another line when they would be well within the column limit if left on the same line? Is there a config option I can use?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bwendlingcommented, Apr 18, 2015

I forgot that we already have an option for this. It’s the SPLIT_BEFORE_NAMED_ASSIGNS option. If you disable it, then it should give you something more reasonable. 😃

0reactions
sawancommented, Apr 22, 2015

Haha… nope did not raise anything, just gave me the same result 😃

Maybe you’re trapping your eval somewhere?

Works now, many thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python what code convention splitting arguments into lines?
Arguments on first line forbidden when not using vertical alignment. foo = long_function_name(var_one, var_two, var_three, var_four).
Read more >
Is it a bad idea to list every function/method argument on a ...
I find that using multiple lines help to make the code readable IF parameters are long expression or a few too many. Otherwise...
Read more >
The Black code style - Black 22.12.0 documentation
Black will add trailing commas to expressions that are split by comma where each element is on its own line. This includes function...
Read more >
Built-in Types — Python 3.11.1 documentation
Line breaks are not included in the resulting list unless keepends is given and true. This method splits on the following line boundaries....
Read more >
Google C++ Style Guide
There is a high bar for style guide waivers on such restrictions, ... In particular, do not add new parameters to the end...
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