summary refs log tree commit diff
path: root/pkgs/development/python-modules/pytest-examples/default.nix
blob: 3ac626a3f997a822eace0fc1743f6a08f405d108 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ lib
, black
, buildPythonPackage
, fetchFromGitHub
, hatchling
, pytest
, pytestCheckHook
, pythonOlder
, pythonRelaxDepsHook
, ruff
}:

buildPythonPackage rec {
  pname = "pytest-examples";
  version = "0.0.10";
  format = "pyproject";

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "pydantic";
    repo = "pytest-examples";
    rev = "refs/tags/v${version}";
    hash = "sha256-jCxOGDJlFkMH9VtaaPsE5zt+p3Z/mrVzhdNSI51/nVM=";
  };

  postPatch = ''
    # ruff binary is used directly, the ruff Python package is not needed
    substituteInPlace pytest_examples/lint.py \
      --replace "'ruff'" "'${ruff}/bin/ruff'"
  '';

  pythonRemoveDeps = [
    "ruff"
  ];

  nativeBuildInputs = [
    hatchling
    pythonRelaxDepsHook
  ];

  buildInputs = [
    pytest
  ];

  propagatedBuildInputs = [
    black
    ruff
  ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  pythonImportsCheck = [
    "pytest_examples"
  ];

  disabledTests = [
    # Test fails with latest ruff v0.1.2
    # See https://github.com/pydantic/pytest-examples/issues/26
    "test_ruff_error"
  ];

  meta = with lib; {
    description = "Pytest plugin for testing examples in docstrings and markdown files";
    homepage = "https://github.com/pydantic/pytest-examples";
    changelog = "https://github.com/pydantic/pytest-examples/releases/tag/v${version}";
    license = licenses.mit;
    maintainers = with maintainers; [ fab ];
  };
}