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