Forbid too many different positional arguments passing
See original GitHub issueRule request
Thesis
If function gets many arguments they all should be keyword.
Bad:
get_report('daily', date_from, date_to, 'pdf', False)
Good:
get_report(period='daily', since=date_from, till=date_to, extension='pdf', cache=False)
Exceptions:
- 1-2 positional parameters:
get_report(since, till)
- Function get
*args
, so all arguments have the same meaning:max(1, 2, 3, 12, 9)
Reasoning
It’s difficult to read. You can regulate it for your code via keyword-only arguments, but in big project it will be useful to forget it for third-party functions calls too.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Python: avoiding Pylint warnings about too many arguments
My point is about having to pass many variables to the extracted function and avoiding the pylint warning if possible (without explicitly making ......
Read more >Python: Keyword arguments and "Functions, methods and ...
Maybe we could consider that the problem of passing too many positional arguments to a function call is a separate problem.
Read more >too-many-arguments / R0913 - Pylint 2.16.0-dev documentation
too -many-arguments / R0913#. Message emitted: Too many arguments (%s/%s). Description: Used when a function or method takes too many arguments.
Read more >Effective Python: 4 Best Practices for Function Arguments
Like most other programming languages, calling a function in Python allows for passing arguments by position.
Read more >Argument Passing in Airflow's Operator Inheritance ... - Medium
A review of *args, **kwargs, and argument passing when extending a class ... If there are too many instance variables, consider breaking up ......
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 FreeTop 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
Top GitHub Comments
As possible solution we can block positional args of different types.
Bad:
Good:
Correct implementation is not possible, I have researched this topic.