Skip to content

Feature: Add option to not detect alignment #834

@eutwt

Description

@eutwt

An option to not detect alignment would be useful. I think disallowing alignment in code style guides is fairly prevalent. PEP 8 advises against it. The top stackoverflow result for the question has split answers, with the top-voted answer advocating strongly against it.

For me personally, the reasons I'd like the styler I use to not allow alignment in code are

  • Alignment can't be done by styler, only ignored. So if someone aligns one call then it is in a different style than the rest of the code after styling, unless I've somehow convinced everyone on the project to manually align all their code. I'd prefer there to be no red-flag "oh I guess Bob wrote this" signs in the codebase post-styling.
  • It requires reviewers of a pull request to review more than they need to. It messes up the commit history / merges / git blame

More on point two in case it isn't obvious what's meant:

Say I'm working on a project and need to add some arguments to this function call. The person who wrote it ran styler, and it was left as-is because it recognized the alignment.

call(
  x = 1,           p = 3,
  y = "something", z = 9
)

Ok, so now I add my arguments

call(
  x = 1,           p = 3,
  y = "something", z = 9,
  areallylongarg = 4, extra_arg = 44,
)

That doesn't look right, let me use styler...

call(
  x = 1, p = 3,
  y = "something", z = 9,
  areallylongarg = 4, extra_arg = 44,
)

After styling the selection line 2 is changed, even though it wasn't part of my code edit. If I submit a pull request, the reviewer will have to read line 2 to make sure I didn't break anything, rather than simply looking at the single line I added. (Ok two lines isn't much but you can imagine cases where there'd be more)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions