Pycodestyle: E123: makes the code more ugly

Created on 10 Jul 2021  路  12Comments  路  Source: PyCQA/pycodestyle

    project = ProjectBuilder() \
        .update_info(
            name=name, version=version
        ) \
        .set_storage(FakeStorage()) \
        .build()

Error got:
E123 closing bracket does not match indentation of opening bracket's line

Fix:

    project = ProjectBuilder() \
        .update_info(
        name=name, version=version
    ) \
        .set_storage(FakeStorage()) \
        .build()

Why does pycodestyle align brackets like that?

All 12 comments

E123 is disabled by default, you've opted into this style (presumably by using ignore instead of extend-ignore)

additionally, "ugly" isn't objective, for example I would ditch the backslashes entirely in your code sample for something like:

x = (
    ThingHere()
    .with_chained(
        things,
    )
    .etc()
)

E123 is disabled by default

My flake config

[flake8]
max-line-length = 120
max-complexity = 18
select = B,C,E,F,G,W,T4,B9
#ignore = E203, E266, E501, W503
ignore =
    E126,
    E127,
    E131,
    E401,
    E402,
    E701,

per-file-ignores =
    __init__.py:F401

exclude =
    .venv,
    .git,
    .tox,
    venv,
    dist,
    doc,
    *openstack/common/*,
    *lib/python*,
    *egg,
    build,
    tools/xenserver*,
    releasenotes,
    migrations

If I write without backslashes

    x = (
        ThingHere()
            .with_chained(
                things,
            )
            .etc()
    )

I've got the error
E123 closing bracket does not match indentation of opening bracket's line

once more with emphasis: presumably by using ignore instead of extend-ignore

You wrote that I myself chose this style,

you've opted into this style

so I wrote my config here. If I have to turn off the check myself then it is not disabled by default as you wrote

E123 is disabled by default,

Please decide whether the E123 check is enabled or disabled by default. And open the issues so that others can also participate in the discussion.

yes, I also wrote a guess that was correct -- you're using ignore instead of extend-ignore which disables the default set of ignores

you're using ignore instead of extend-ignore which disables the default set of ignores

Oh, now I get it, thanks. Replace ignore to extend-ignore.

And open the issues so that others can also participate in the discussion.

Not when those "participating" aren't listening to us, no.

I'm really curious right now.
Does everyone think this code is not formatted correctly?

    project = ProjectBuilder() \
        .update_info(
            name=name, version=version
        ) \
        .set_storage(FakeStorage()) \
        .build()

But this one is correct

    project = ProjectBuilder() \
        .update_info(
        name=name, version=version
    ) \
        .set_storage(FakeStorage()) \
        .build()

I just pointed out the problem in rule E123. In response, you told me to ignore E123. Hmm, why not ignore all the rules at all? Can you suggest removing pyflake8 altogether? Why stop?

many of the rules are _opinionated_ or _conflicting_ and therefore disabled by default. E123 is one such rule (and it's very clear you don't like its opinion so you shouldn't turn it on)

I think both of your examples are hideous

I think both of your examples are hideous

Okey, examples without backslashes

Bad

project = (
        ProjectBuilder()
            .update_info(
            name=project_name, version=project_version
        )
            .set_local_storage()
            .build()
    )

Good

project = (
    ProjectBuilder()
        .update_info(
            name=project_name, version=project_version
        )
        .set_local_storage()
        .build()
)

neither of those match my suggestion above: https://github.com/PyCQA/pycodestyle/issues/1004#issuecomment-877492803

I've locked this conversation for the following reasons:

  • It's not productive at this point
  • It is born out of poor usage of a tool and it's configuration
  • It's effectively resolved because the solution is to fix the usage of the configuration
  • It's turned into "You're wrong because your opinion isn't mine and I'm going to berate you into changing that" and that's not productive for anyone.
Was this page helpful?
0 / 5 - 0 ratings