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