tailscale: build derpprobe (#364918)
[NixPkgs.git] / pkgs / by-name / nb / nbqa / package.nix
blobe171b4b57556807c6e8ebd9f41fd6e8fbdb3becc
2   lib,
3   python3Packages,
4   fetchFromGitHub,
6   # optional-dependencies
7   ruff,
9   # tests
10   versionCheckHook,
12   nix-update-script,
15 let
16   nbqa = python3Packages.buildPythonApplication rec {
17     pname = "nbqa";
18     version = "1.9.1";
19     pyproject = true;
21     src = fetchFromGitHub {
22       owner = "nbQA-dev";
23       repo = "nbQA";
24       rev = "refs/tags/${version}";
25       hash = "sha256-qVNJ8f8vUlTCi5DbvG70orcSnulH60UcI5iABtXYUog=";
26     };
28     build-system = with python3Packages; [
29       setuptools
30     ];
32     optional-dependencies.toolchain =
33       (with python3Packages; [
34         black
35         blacken-docs
36         flake8
37         isort
38         jupytext
39         mypy
40         pylint
41         pyupgrade
42       ])
43       ++ [
44         ruff
45       ];
47     dependencies = with python3Packages; [
48       autopep8
49       ipython
50       tokenize-rt
51       tomli
52     ];
54     postPatch = ''
55       # Force using the Ruff executable rather than the Python package
56       substituteInPlace nbqa/__main__.py --replace 'if shell:' 'if shell or main_command == "ruff":'
57     '';
59     preCheck = ''
60       # Allow the tests to run `nbqa` itself from the path
61       export PATH="$out/bin":"$PATH"
62     '';
64     nativeCheckInputs =
65       (with python3Packages; [
66         autoflake
67         distutils
68         mdformat
69         pre-commit-hooks
70         pydocstyle
71         pytestCheckHook
72         yapf
73       ])
74       ++ lib.flatten (lib.attrValues optional-dependencies)
75       ++ [ versionCheckHook ];
76     versionCheckProgramArg = [ "--version" ];
78     disabledTests = [
79       # Test data not found
80       "test_black_multiple_files"
81       "test_black_return_code"
82       "test_grep"
83       "test_jupytext_on_folder"
84       "test_mypy_works"
85       "test_running_in_different_dir_works"
86       "test_unable_to_reconstruct_message_pythonpath"
87       "test_with_subcommand"
88       "test_pylint_works"
89     ];
91     disabledTestPaths = [
92       # Test data not found
93       "tests/test_include_exclude.py"
94     ];
96     passthru = {
97       # selector is a function mapping pythonPackages to a list of code quality
98       # tools, e.g. nbqa.withTools (ps: [ ps.black ])
99       withTools =
100         selector:
101         nbqa.overridePythonAttrs (
102           { dependencies, ... }:
103           {
104             dependencies = dependencies ++ selector python3Packages;
105             doCheck = false;
106           }
107         );
109       updateScript = nix-update-script { };
110     };
112     meta = {
113       homepage = "https://github.com/nbQA-dev/nbQA";
114       changelog = "https://nbqa.readthedocs.io/en/latest/history.html";
115       description = "Run ruff, isort, pyupgrade, mypy, pylint, flake8, black, blacken-docs, and more on Jupyter Notebooks";
116       license = lib.licenses.mit;
117       maintainers = with lib.maintainers; [ l0b0 ];
118       mainProgram = "nbqa";
119     };
120   };
122 nbqa