-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lift pylint ignore: too-many-positional-arguments #137
Comments
@bh2smith I would like to contribute. Can you assign me this issue? |
Sure thing. Go for it. |
List of Functions that need to be revamped. ************* Module dune_client.client_async |
@bh2smith How to handle params for create_table function? dune-client/dune_client/api/table.py Lines 55 to 62 in 7d7d14e
We can create a dict with all the params and pass it in line 75. dune-client/dune_client/api/table.py Lines 75 to 81 in 7d7d14e
Thoughts? |
PR raised for this issue - #139 |
This came up in #136 - Here are some AI suggestions:
The Pylint error R0917: Too many positional arguments (8/5) indicates that a function or method is being called with more than the recommended number of positional arguments (the default limit is 5). This is generally considered a code smell because it suggests that the function might be doing too much or its parameters could be better organized.
Solutions
If many of the arguments have a logical grouping or hierarchy, you can use keyword arguments to make the function call more readable and avoid using too many positional arguments.
Instead of passing many individual arguments, consider grouping related arguments into a dictionary or a custom class.
Reduce the number of required positional arguments by assigning default values to some of them.
How to Address the Issue in Your Code
In your case, you can:
Example Solution
Let’s assume the method some_function is causing the issue. Here’s how you can refactor it:
Original Method (Example)
If this is being called with 8 positional arguments like:
This will trigger the R0917 error.
Refactored Solution
Then call it like this:
If you want more structure, use a named tuple or a data class:
Then call it like this:
This way, you reduce the number of positional arguments passed to the function and increase the readability of your code.
Applying the Solution to Your Case
Given the specific function signature you shared, you can apply either of the two approaches above based on your preference and the specific codebase context. If you provide me with the exact method signature and context where the error is occurring, I can give a more targeted solution tailored to that code snippet!
The text was updated successfully, but these errors were encountered: