-
Notifications
You must be signed in to change notification settings - Fork 360
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
add pyproject.toml #1800
add pyproject.toml #1800
Conversation
it's obviously completely subjective, but personally I find 120 to be too long since it causes too many wrapped lines in my editor - I usually go with 100. |
This is going to be fun 🤣.
I find 80/88 to be too narrow and >125 to be too wide. Hence, I'm good with any value between 100 and 120. Nonetheless, I wanted to use this issue for discussion too. We should be able to document how each contributor can use a different value locally, and use hooks or some other helper script for converting to/from their desired value. There is CLI option $ black pyGHDL -l 100 Very unfortunately, I found that black is not deterministic... Try the following: $ black pyGHDL -l 50
$ black pyGHDL -l 120
$ black pyGHDL -l 100
$ black pyGHDL I would expect no changes after the last call, since that's the default in the repo. But you will see that some of the modifications done in |
pyGHDL/lsp/lsp.py
Outdated
"Caught exception while handling {}, " | ||
+ "see VHDL language server output for details." | ||
).format(method), | ||
("Caught exception while handling {}, " + "see VHDL language server output for details.").format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless of line length, the +
here is unnecessary. Weird that black doesn't catch something like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @umarcor mentioned I personally use longer lines in my personal projects. For pyGHDL, I did a test with black (default = unreasonable 88 chars) with 120 chars and 160 chars. Against 80/88 chars:
For is for 120 chars:
Against 160 chars:
I don't want to use short variable names and ambivalent abbreviations so black can format my code in a compact form. Another idea for avoiding long lines is to change the indentation for 4 to 2 spaces like it's used by JSON, YAML, XML, ... So personally, I don't like black as it makes us all slaves of a tool not supporting code coding styles for readability and efficiency, but rather a fixed pattern so programmers are force the workaround the rules of black. |
That would go directly against PEP 8, which is the one standard almost everyone agrees should be a base for any python formatting. Then again, it also mandates 80 character lines... The ideal solution for this would of course be tabs, which everyone can set to whatever width they want, but that doesn't work for python (because you wouldn't be able to use spaces for alignment). |
Agree.
I would be good with any other alternative, such as yapf (see https://www.kevinpeters.net/auto-formatters-for-python). However, someone needs to go through the options of those non-opinionated formatters and select some defaults. If they can provide deterministic output for varying contributor configurations, I believe the change is sensible. Personally, I don't mind dealing with the annoyances of black, as I wouldn't mind dealing with the ones from any other formatter or style preference. What I cannot and don't want to do is to learn coding styles myself. |
00f3f9a
to
3cca177
Compare
@tgingold what do you think about 120 chars compared to 88 chars default from back. Currently black creates such ugly code: return cls(
variableNode,
[
name,
],
subtypeIndication,
) |
I don't have a strong opinion. Please choose!
|
I rebased and addressed the usage of I propose we merge this (black with 120 char setting), until we find an alternative formatter which generates deterministic output. |
This PR adds a
pyproject.toml
file for specifying the line-length used byblack
, which is increased from 88 to 120.