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

PEP8 should allow whitespace for tables of data #1428

Closed
endolith opened this issue Jun 13, 2020 · 7 comments
Closed

PEP8 should allow whitespace for tables of data #1428

endolith opened this issue Jun 13, 2020 · 7 comments

Comments

@endolith
Copy link

endolith commented Jun 13, 2020

The purpose of PEP8 is to promote readability, but it's currently interpreted to prohibit tables like this:

                 [[          0,           0,           0,    0,          0],
                  [ 1518491136,  2147432704,  1518419200,    0,  821805056],
                  [ 2147474176,           0, -2147398656, -768, 1518498560],
                  [ 1518499328, -2147479296,  1518492928,    0, 1984015872],
                  [       -256,           0,        -512,  512, 2147481600],
                  [-1518491648,  2147433728, -1518420992, -512, 1984013056],
                  [-2147472128,           0,  2147377920, -512, 1518498048],
                  [-1518496256, -2147460096, -1518462464,  512,  821805824],
                  [          0,           0,           0,  256,       -256]]

in favor of tables without extra whitespace like this:

                 [[0, 0, 0, 0, 0],
                  [1518491136, 2147432704, 1518419200, 0, 821805056],
                  [2147474176, 0, -2147398656, -768, 1518498560],
                  [1518499328, -2147479296, 1518492928, 0, 1984015872],
                  [-256, 0, -512, 512, 2147481600],
                  [-1518491648, 2147433728, -1518420992, -512, 1984013056],
                  [-2147472128, 0, 2147377920, -512, 1518498048],
                  [-1518496256, -2147460096, -1518462464, 512, 821805824],
                  [0, 0, 0, 256, -256]])

which I think is not nearly as readable.

I think this is a misinterpretation of intent, but pycodestyle will not change this behavior, because they are trying to follow PEP8 to the letter: PyCQA/pycodestyle#289

So can PEP8 be changed to explicitly allow formatting tables of data like this? I've listed a bunch of other examples in that issue: PyCQA/pycodestyle#289 (comment)

See also spyder-ide/spyder#9955 and this PR failure.

@Rosuav
Copy link
Contributor

Rosuav commented Jun 13, 2020

This is an administrative repository. If you want the substance of PEP 8 to be changed, start appealing elsewhere.

And good luck.

@Rosuav Rosuav closed this as completed Jun 13, 2020
@endolith
Copy link
Author

sigh

Start appealing where, exactly?

@gvanrossum
Copy link
Member

With whoever forces you to follow PEP 8 literally without allowing common sense to prevail, obviously. The PEP even says that.

@endolith
Copy link
Author

@gvanrossum I already tried that and they closed and locked the issue:

This project also does its best to implement the rules as enumerated in the official document. We do our best to not try to interpret the intent because that's far too open to wholly subjective interpretation which would be far harder to maintain over the course of years and different maintainers with different interpretations and opinions.

I don't know where else to go. Do you agree that aligning tables of numbers with extra whitespace is better?

@gvanrossum
Copy link
Member

I think you should follow their advice.

@endolith
Copy link
Author

I think you should follow their advice.

Do you mean this comment?

If you were to use a different tool, like Flake8, you could disable E201, E202, and E222 and implement your own plugin that allows tables (which pycodestyle doesn't even today know how to detect and I suspect would be complex and error-prone in practice) to do whatever they want within reason while preventing everything else from violating what would otherwise be caught by E201, E202, and E222

So NumPy, SciPy, etc. should switch from pycodestyle to Flake8 for linting, and implement a plugin to allow whitespace for aligning arrays?

@Rosuav
Copy link
Contributor

Rosuav commented Jun 14, 2020

I don't know. Maybe ask the NumPy or SciPy people?

(a) The Python Steering Council does not decide this question.
(b) Even if it did, this git repository and associated tracker is not the place to request a change.

Please take this matter elsewhere. We cannot help you here.

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

No branches or pull requests

3 participants