-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Rule] Extra level of indentation #6893
Comments
Why is the indentation a problem here? Is the thinking here that would want to upgrade Black to latest, and use Ruff to modify the code to add the 8-space indentation? Or is Ruff flagging the 8-space indentation, and you want to avoid Ruff raising errors there? I think I understand the use-case but I don't know that we can justify adding a rule for this -- it's a fairly specific need, but something we'll need to implement and maintain in perpetuity. |
@charliermarsh Hi! Thank you for a detailed answer.
The indentation is not a problem by itself. The problem is that Black switched the indentation without giving a way to configure it. Both 4 and 8 spaces are ok by PEP 8 if I understand it correctly.
Yes, exactly. I want to use Ruff to temporarily force it back to 8 spaces. After that I will use Ruff's .toml to configure sub-projects finely.
Actually it isn't flagging neither 4 nor 8 spaces. And I haven't met a rule in Ruff which isn't configurable via .toml.
I understand that it is a bit niche use-case. Not many people are skipping so many updates to catch up =) But for me this rule is a bit like a setting of single and double quotes (a problem with no way to use single quotes in Black). And I actually use Q000 and COM812 to decrease the diff, too. |
I'm going to close this in favor of the discussion happening in our own formatter here: #7310 (comment). Feel free to chime in there. I think we're unlikely to support this as a standalone lint rule, but perhaps it will end up being supported in our formatter. |
Similar to #8360 |
Hello!
Black is great and uncompromising but has changed over the years.
I am migrating a large codebase and the diff's size is insane. I hope to make the process more gradual.
I use ruff with autofixes to decrease the diff. Having a monorepo-compatible configuration helps a lot.
After the migration I will change configs in each sub-project separately.
The only problem left for me is an indentation. Our very old version of black puts extra level of space (8 in total) before the args, according to PEP 8. The modern black only uses one level of space (just 4).
Is it possible to add the number of spaces as a custom rule in ruff with autofix?
P.S.: I can't migrate in smaller chunks because the whole codebase uses common tooling and CI.
The text was updated successfully, but these errors were encountered: