2021-03-19 17:17:44 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
2023-04-29 16:46:19 +00:00
|
|
|
, isPyPy
|
2021-03-19 17:17:44 +00:00
|
|
|
, nose
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "yapf";
|
2022-01-26 04:04:25 +00:00
|
|
|
version = "0.32.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-01-26 04:04:25 +00:00
|
|
|
hash = "sha256-o/UIXTfvfj4ATEup+bPkDFT/GQHNER8FFFrjE6fGfRs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
# nose is unavailable on pypy
|
|
|
|
doCheck = !isPyPy;
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2021-03-19 17:17:44 +00:00
|
|
|
nose
|
|
|
|
];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2021-03-19 17:17:44 +00:00
|
|
|
homepage = "https://github.com/google/yapf";
|
|
|
|
description = "Yet Another Python Formatter";
|
|
|
|
longDescription = ''
|
|
|
|
Most of the current formatters for Python --- e.g., autopep8, and pep8ify
|
|
|
|
--- are made to remove lint errors from code. This has some obvious
|
|
|
|
limitations. For instance, code that conforms to the PEP 8 guidelines may
|
|
|
|
not be reformatted. But it doesn't mean that the code looks good.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
YAPF takes a different approach. It's based off of 'clang-format',
|
|
|
|
developed by Daniel Jasper. In essence, the algorithm takes the code and
|
|
|
|
reformats it to the best formatting that conforms to the style guide, even
|
|
|
|
if the original code didn't violate the style guide. The idea is also
|
|
|
|
similar to the 'gofmt' tool for the Go programming language: end all holy
|
|
|
|
wars about formatting - if the whole codebase of a project is simply piped
|
|
|
|
through YAPF whenever modifications are made, the style remains consistent
|
|
|
|
throughout the project and there's no point arguing about style in every
|
|
|
|
code review.
|
|
|
|
|
|
|
|
The ultimate goal is that the code YAPF produces is as good as the code
|
|
|
|
that a programmer would write if they were following the style guide. It
|
|
|
|
takes away some of the drudgery of maintaining your code.
|
|
|
|
'';
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ AndersonTorres siddharthist ];
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|