wemake-services / wemake-python-styleguide

The strictest and most opinionated python linter ever!
https://wemake-python-styleguide.rtfd.io
MIT License
2.49k stars 381 forks source link

Comparison of tools #1059

Open DonaldTsang opened 4 years ago

DonaldTsang commented 4 years ago

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?

sobolevn commented 4 years ago

@DonaldTsang well, you have listed a big list of very different tools!

DonaldTsang commented 4 years ago

What 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 ?

sobolevn commented 4 years ago

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.

DonaldTsang commented 4 years ago

So 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.

sobolevn commented 4 years ago

@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?

DonaldTsang commented 4 years ago

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.

DonaldTsang commented 4 years ago

Counter point form black: Some of the incompatibility can be stomped out by adding parameters:

sobolevn commented 4 years ago

Not really. That's what is discussed here #518 #890

DonaldTsang commented 4 years ago

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"?

sobolevn commented 4 years ago

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.

DonaldTsang commented 4 years ago

@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?

sobolevn commented 4 years ago

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.

DonaldTsang commented 4 years ago

@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.