Splitting function arguments into new lines when column limit not reached
See original GitHub issueTurned 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:
- Created 8 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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. 😃Haha… nope did not raise anything, just gave me the same result 😃
Maybe you’re trapping your
eval
somewhere?Works now, many thanks.