1{ lib
2, buildPythonPackage
3, fetchPypi
4, isPyPy
5, nose
6, importlib-metadata
7, platformdirs
8, tomli
9}:
10
11buildPythonPackage rec {
12 pname = "yapf";
13 version = "0.40.1";
14
15 src = fetchPypi {
16 inherit pname version;
17 hash = "sha256-lYWH61yOxshgEZqcJdAq3fMKRPdaoVKkIg0w5WqYA3w=";
18 };
19
20 # nose is unavailable on pypy
21 doCheck = !isPyPy;
22
23 propagatedBuildInputs = [
24 importlib-metadata
25 platformdirs
26 tomli
27 ];
28
29 nativeCheckInputs = [
30 nose
31 ];
32
33 meta = {
34 homepage = "https://github.com/google/yapf";
35 description = "Yet Another Python Formatter";
36 longDescription = ''
37 Most of the current formatters for Python --- e.g., autopep8, and pep8ify
38 --- are made to remove lint errors from code. This has some obvious
39 limitations. For instance, code that conforms to the PEP 8 guidelines may
40 not be reformatted. But it doesn't mean that the code looks good.
41
42 YAPF takes a different approach. It's based off of 'clang-format',
43 developed by Daniel Jasper. In essence, the algorithm takes the code and
44 reformats it to the best formatting that conforms to the style guide, even
45 if the original code didn't violate the style guide. The idea is also
46 similar to the 'gofmt' tool for the Go programming language: end all holy
47 wars about formatting - if the whole codebase of a project is simply piped
48 through YAPF whenever modifications are made, the style remains consistent
49 throughout the project and there's no point arguing about style in every
50 code review.
51
52 The ultimate goal is that the code YAPF produces is as good as the code
53 that a programmer would write if they were following the style guide. It
54 takes away some of the drudgery of maintaining your code.
55 '';
56 license = lib.licenses.asl20;
57 maintainers = with lib.maintainers; [ AndersonTorres siddharthist ];
58 };
59}