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

Feature Request: Indents #3907

Closed
navyamehta opened this issue Apr 7, 2023 · 5 comments
Closed

Feature Request: Indents #3907

navyamehta opened this issue Apr 7, 2023 · 5 comments
Labels
question Asking for support or clarification

Comments

@navyamehta
Copy link

Is there a way to directly specify the indentation style to apply in a codebase (4-space indent vs hanging indent etc.) via a config in ruff.toml? Thank you!

@charliermarsh
Copy link
Member

It doesn't exist right now, but it would likely be part of the formatter configuration eventually :)

@charliermarsh charliermarsh added the question Asking for support or clarification label Apr 13, 2023
@chiamp
Copy link

chiamp commented Nov 3, 2023

I would also be interested in a feature where you can configure regular indent and hanging indent separately

@cgarciae
Copy link

cgarciae commented Nov 3, 2023

Just want to add that this would be important for Google-related Open Source projects.

@zanieb
Copy link
Member

zanieb commented Nov 3, 2023

I presume our existing formatter indentation configuration does not satisfy your requirement? https://docs.astral.sh/ruff/formatter/#configuration

Can you provide some concrete examples of what you need?

@cgarciae
Copy link

cgarciae commented Nov 3, 2023

Hey @zanieb! Sure, so here is how it currently formats a function with a trailing comma in the arguments (or if the arguments are too long) using 2 space indentation:

some_func(
  foo,
  bar,
)

Some Google projects use 2 space indentation with 4 space hanging indentation:

some_func(
    foo,
    bar,
)

We are currently testing migrating from pyink to ruff, pyink does implement 4 space hanging indentation on 2 space indentation. You can try it out with the following config:

[tool.pyink]
pyink-indentation = 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

5 participants