Forbid returning too long tuples
See original GitHub issueRule request
Thesis
Forbid returning a too long constant-length tuple from a function:
# bad
def hello():
return 1, 2, 3, 4
When there are more than 2 values must be returned, use dataclasses.dataclass, typing.NamedTuple, or attrs instead.
Reasoning
Code readability and maintainability: the caller code must know exact order of all components which is easy to mess up. A real-world example:
time, phase, spacing, size, version, error, series_type = read_result_log()
😩
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Ignoring part of a tuple returned in Python? - Stack Overflow
With the following code, is there any way to specify that I don't care about the 'address' part of the tuple returned?
Read more >Returning and Consuming Tuples - Pluralsight
In this guide, we are going to look at how to create tuples in C#, how to return them from methods and how...
Read more >Tuples are ok - DEV Community
Long tuples can be a pain, the biggest reason is that with longer tuple its harder to remember at which position stands which...
Read more >Code Smell:System.Tuple - Passion for Coding
Typical use of tuples include allowing multiple return values for functions or storing temporary data inside a method.
Read more >Why not tuples? - Google Groups
solution is to disallow destructuring in a map assignment. ... I think there is no really big reason to make a special tuple...
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
Please assign me, I am finishing PR for this task.
Exactly! I don’t see a reason why
return
is any different fromyield
from this perspective 😃