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

Comparison of tools #1059

Closed
DonaldTsang opened this issue Dec 8, 2019 · 13 comments
Closed

Comparison of tools #1059

DonaldTsang opened this issue Dec 8, 2019 · 13 comments
Labels
documentation Docs related task question Further information is requested

Comments

@DonaldTsang
Copy link

DonaldTsang commented Dec 8, 2019

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
Copy link
Member

sobolevn commented Dec 8, 2019

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

@sobolevn sobolevn added documentation Docs related task question Further information is requested labels Dec 8, 2019
@DonaldTsang
Copy link
Author

DonaldTsang commented Dec 8, 2019

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
Copy link
Member

sobolevn commented Dec 8, 2019

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 code
  • bandit is our dependency that defines how to write secure python code

@DonaldTsang
Copy link
Author

DonaldTsang commented Dec 8, 2019

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
Copy link
Member

sobolevn commented Dec 8, 2019

@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
Copy link
Author

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
Copy link
Author

DonaldTsang commented Dec 8, 2019

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

@sobolevn
Copy link
Member

sobolevn commented Dec 8, 2019

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

  • We enforce ' when black can only ignore string quotes and not convert double quotes to single quotes " -> '
  • Line length in black is fluid, please see docs: it equals to 80 +- 10%

@DonaldTsang
Copy link
Author

DonaldTsang commented Dec 8, 2019

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
Copy link
Member

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
Copy link
Author

@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
Copy link
Member

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
Copy link
Author

DonaldTsang commented Dec 11, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Docs related task question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants