-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
Forbid returning too long tuples #1731
Comments
We already have:
and
Maybe it is a good idea to simplify them into a single rule. On the other hand, I like to define long immutable sequences as tuples. I guess that this should be allowed. |
Hmm. I tried the snippet above on flakehell.orsinium.dev and it hasn't found anything 🤔 I'm wondering what I did wrong. |
Oh, I see, it's only about
Sure. This is why I said "constant-length". When you use a tuple as an immutable list (when the length is unknown in advance), it is fine. |
@sobolevn So am I understanding correctly, that the issue realization must just add full |
Exactly! I don't see a reason why |
Please assign me, I am finishing PR for this task. |
* Closes #1731 * Update CHANGELOG.md Co-authored-by: Nikita Sobolev <[email protected]>
Rule request
Thesis
Forbid returning a too long constant-length tuple from a function:
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:
😩
The text was updated successfully, but these errors were encountered: