Open DonaldTsang opened 4 years ago
@DonaldTsang well, you have listed a big list of very different tools!
yapf
is an autoformatter similar to black
. It is not supportedautopep8
is an autoformatter similar to black
. However, it is supported. The style it produces is a valid wemake-python-styleguide
style. See: https://github.com/wemake-services/wemake-python-styleguide/blob/master/Makefile#L7coala
is a wrapper around linting tools. flake8
is not supported by it: https://github.com/coala/coala-bears/issues/169What is the difference between an autoformatter and a linter? so black, yapf and autopep8 are all things that are meant to be use before/after WPS? Forgot to ask, what are https://github.com/PyCQA/pyflakes and https://github.com/PyCQA/bandit ?
You can read more about auto-formatters and linters here: https://wemake-python-stylegui.de/en/latest/pages/usage/integrations/auto-formatters.html
Short answer: we expect people to use wps
instead of any auto-formatters.
Because not auto-formatter can refactor your code to be readable and pretty.
pyflakes
is our dependency that defines some basic rules on how to write python codebandit
is our dependency that defines how to write secure python codeSo the reason why yapf is not supported is that it is too complex, and that black is not supported becasue it is opinionated reagarding double-quotes, removal of trailing commas and extended line lengths? Also, would like to see coala be included in https://wemake-python-stylegui.de/en/latest/pages/usage/integrations/auto-formatters.html for future versions.
@DonaldTsang Yes, that's correct.
I haven't used coala
at all, can you please add a line or two about it to the docs?
Quoting https://coala.io/
coala provides a unified interface for linting and fixing code with a single configuration file, regardless of the programming languages used. You can use coala from within your favorite editor, integrate it with your CI, get the results as JSON, or customize it to your needs with its flexible configuration syntax. coala supports popular programming languages including Python, C/C++, Java, JavaScript, CSS, and several others out of the box.
The documentation website is wonky though.
Counter point form black: Some of the incompatibility can be stomped out by adding parameters:
--skip-string-normalization
--line-length (and edit config)
(seem to have no solutions?)
Not really. That's what is discussed here #518 #890
'
when black
can only ignore string quotes and not convert double quotes to single quotes "
-> '
black
is fluid, please see docs: it equals to 80
+- 10%
We enforce ' when black can only ignore string quotes and not convert double quotes to single quotes " -> '
Does that mean the original black double-quote standard can just be made compatible with WPS through regex?
Line length in black is fluid, please see docs: it equals to 80 +- 10%
It says "Alternatively, use Bugbear's B950 warning instead of E501 and keep the max line length at 80 which you are probably already using" so are they deceiving us with the hard limit?
Another note: in https://github.com/wemake-services/wemake-python-styleguide#what-we-are-about is it possible to add a star to WPS and others where autopep8 can be used together with the linter, such that it is "technically supported with caveats of not being one single package"?
Well, autopep8
is not "supported". It just can be used together with this tool.
We have lot's of issues that cannot be covered by any auto-formatter, including black
and autopep8
. That's why we don't want to focus on them. Because there's no "make this code great" button that can theoretically exist.
If user wants to fix some whitespaces and indentation, that's ok - autopep8
might be used.
But, if user wants to have a highly maintainable codebase - well, one has to do some manual work.
@sobolevn for WPS there are standards that are based on formatting and standards that are based on quality, I would expect that autoformatters fixes all formatting related standards while leaving the quality-related standard for people to handle. Is my expectation correct?
Not really. The gap between formatting and quality is really thin. For example, fixing some formatting issues might trigger quality rules. And that's how this project is designed.
However, I know what you are talking about. For example, eslint --fix
works this way. But, it sometimes requires multiple iterations to fix some problems, like:
{a: 1}
-> { "a": 1 }
-> { 'a': 1 }
Not sure that we will be able to support this feature. It requires too much effort.
@sobolevn it is worth considering as many shortcuts as possible, in order to save work that is not needed when thinking about semi-trivial code formatting, and instead on "code cleanness" that is actually important. This might be the reason why black or yapf is much more popular than WPS.
So what are the differences between WPS and these other tools, is it possible to add them to the table in the ReadME? If they are supplementary, how so?