Skip to content
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

How to configure Ruff to disallow double assignments in single lines in Python? #11317

Open
javinba opened this issue May 7, 2024 · 2 comments
Labels
rule Implementing or modifying a lint rule

Comments

@javinba
Copy link

javinba commented May 7, 2024

I'm looking for a way to configure Ruff to disallow double assignments in single lines, like this:

name, position = files.name, pos

Instead, I want the linter to enforce separate assignments on separate lines, like this:

name = files.name
position = pos

However, I still want to allow tuple unpacking, like this:

name, position = extract_details()

Is there a way to configure Ruff to achieve this behavior?

@MichaReiser
Copy link
Member

I don't think such a rule exists today. I just tried to see if Ruff flags the assignment when enabling all rules but it doesn't.

https://play.ruff.rs/e1feb7f2-7c32-4bfd-ae87-b12102a382a4

@javinba
Copy link
Author

javinba commented May 7, 2024

Hi @MichaReiser , thanks for replying. Do you think it would be possible to add this rule? 🙂

@zanieb zanieb added the rule Implementing or modifying a lint rule label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

3 participants