Unverified Commit cb876f18 authored by Robert Schütz's avatar Robert Schütz Committed by GitHub
Browse files

nbqa: add passthru.withTools (#343632)

parents fa040ba2 479a1a6c
Loading
Loading
Loading
Loading
+91 −89
Original line number Diff line number Diff line
@@ -4,15 +4,14 @@
  fetchFromGitHub,

  # optional-dependencies
  black,
  blacken-docs,
  ruff,

  # passthru
  testers,
  nbqa,
  # tests
  versionCheckHook,
}:
python3.pkgs.buildPythonApplication rec {

let
  nbqa = python3.pkgs.buildPythonApplication rec {
    pname = "nbqa";
    version = "1.9.0";
    pyproject = true;
@@ -28,27 +27,27 @@ python3.pkgs.buildPythonApplication rec {
      setuptools
    ];

  passthru.optional-dependencies = {
    black = [ black ];
    blacken-docs = [ blacken-docs ];
    flake8 = [ python3.pkgs.flake8 ];
    isort = [ python3.pkgs.isort ];
    jupytext = [ python3.pkgs.jupytext ];
    mypy = [ python3.pkgs.mypy ];
    pylint = [ python3.pkgs.pylint ];
    pyupgrade = [ python3.pkgs.pyupgrade ];
    ruff = [ ruff ];
  };
    optional-dependencies.toolchain =
      (with python3.pkgs; [
        black
        blacken-docs
        flake8
        isort
        jupytext
        mypy
        pylint
        pyupgrade
      ])
      ++ [
        ruff
      ];

  dependencies =
    with python3.pkgs;
    [
    dependencies = with python3.pkgs; [
      autopep8
      ipython
      tokenize-rt
      tomli
    ]
    ++ builtins.attrValues passthru.optional-dependencies;
    ];

    postPatch = ''
      # Force using the Ruff executable rather than the Python package
@@ -61,24 +60,17 @@ python3.pkgs.buildPythonApplication rec {
    '';

    nativeCheckInputs =
    [
      black
      ruff
    ]
    ++ (with python3.pkgs; [
      (with python3.pkgs; [
        autoflake
        distutils
      flake8
      isort
      jupytext
        mdformat
        pre-commit-hooks
        pydocstyle
      pylint
        pytestCheckHook
      pyupgrade
        yapf
    ]);
      ])
      ++ lib.flatten (lib.attrValues optional-dependencies)
      ++ [ versionCheckHook ];

    disabledTests = [
      # Test data not found
@@ -99,9 +91,17 @@ python3.pkgs.buildPythonApplication rec {
    ];

    passthru = {
    tests.version = testers.testVersion {
      package = nbqa;
    };
      # selector is a function mapping pythonPackages to a list of code quality
      # tools, e.g. nbqa.withTools (ps: [ ps.black ])
      withTools =
        selector:
        nbqa.overridePythonAttrs (
          { dependencies, ... }:
          {
            dependencies = dependencies ++ selector python3.pkgs;
            doCheck = false;
          }
        );
    };

    meta = {
@@ -112,4 +112,6 @@ python3.pkgs.buildPythonApplication rec {
      maintainers = with lib.maintainers; [ l0b0 ];
      mainProgram = "nbqa";
    };
}
  };
in
nbqa
+14 −11
Original line number Diff line number Diff line
{ black
, fetchFromGitHub
, lib
, python3
{
  black,
  buildPythonPackage,
  fetchFromGitHub,
  lib,
  pytestCheckHook,
  setuptools,
}:
python3.pkgs.buildPythonApplication rec {

buildPythonPackage rec {
  pname = "blacken-docs";
  version = "1.15.0";
  format = "pyproject";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "adamchainz";
@@ -15,17 +19,16 @@ python3.pkgs.buildPythonApplication rec {
    hash = "sha256-3FGuFOAHCcybPwujWlh58NWtuF5CebaKTgBWgCGpSL8=";
  };

  nativeBuildInputs = [
    python3.pkgs.setuptools
  build-system = [
    setuptools
  ];

  propagatedBuildInputs = [
  dependencies = [
    black
  ];

  nativeCheckInputs = [
    black
    python3.pkgs.pytestCheckHook
    pytestCheckHook
  ];

  meta = with lib; {
+1 −1
Original line number Diff line number Diff line
@@ -6609,7 +6609,7 @@ with pkgs;
  bbin = callPackage ../development/tools/bbin { };
  blacken-docs = callPackage ../tools/misc/blacken-docs { };
  blacken-docs = with python3Packages; toPythonApplication blacken-docs;
  bore = callPackage ../tools/networking/bore {
    inherit (darwin) Libsystem;
+2 −0
Original line number Diff line number Diff line
@@ -1667,6 +1667,8 @@ self: super: with self; {
  black = callPackage ../development/python-modules/black { };
  blacken-docs = callPackage ../development/python-modules/blacken-docs { };
  blackjax = callPackage ../development/python-modules/blackjax { };
  black-macchiato = callPackage ../development/python-modules/black-macchiato { };