PyCQA / pycodestyle

Simple Python style checker in one Python file
https://pycodestyle.pycqa.org
Other
5.03k stars 756 forks source link

E123: makes the code more ugly #1004

Closed heckad closed 3 years ago

heckad commented 3 years ago
    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?

asottile commented 3 years ago

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()
)
heckad commented 3 years ago

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

asottile commented 3 years ago

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

heckad commented 3 years ago

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.

asottile commented 3 years ago

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

heckad commented 3 years ago

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.

sigmavirus24 commented 3 years ago

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

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

heckad commented 3 years ago

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?

asottile commented 3 years ago

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

heckad commented 3 years ago

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()
)
asottile commented 3 years ago

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

sigmavirus24 commented 3 years ago

I've locked this conversation for the following reasons: