1{
2 lib,
3 black,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 hatchling,
8 pytest,
9 pytestCheckHook,
10 pythonOlder,
11 pythonRelaxDepsHook,
12 ruff,
13}:
14
15buildPythonPackage rec {
16 pname = "pytest-examples";
17 version = "0.0.10";
18 format = "pyproject";
19
20 disabled = pythonOlder "3.8";
21
22 src = fetchFromGitHub {
23 owner = "pydantic";
24 repo = "pytest-examples";
25 rev = "refs/tags/v${version}";
26 hash = "sha256-jCxOGDJlFkMH9VtaaPsE5zt+p3Z/mrVzhdNSI51/nVM=";
27 };
28
29 patches = [
30 (fetchpatch {
31 url = "https://github.com/pydantic/pytest-examples/commit/551ba911713c2859caabc91b664723dd6bc800c5.patch";
32 hash = "sha256-Y3OU4fNyLADhBQGwX2jY0gagVV2q2dcn3kJRLUyCtZI=";
33 })
34 (fetchpatch {
35 url = "https://github.com/pydantic/pytest-examples/commit/3bef5d644fe3fdb076270833768e4c6df9148530.patch";
36 hash = "sha256-pf+WKzZNqgjbJiblMMLHWk23kjg4W9nm+KBmC8rG8Lw=";
37 })
38 ];
39
40 postPatch = ''
41 # ruff binary is used directly, the ruff Python package is not needed
42 substituteInPlace pytest_examples/lint.py \
43 --replace "'ruff'" "'${ruff}/bin/ruff'"
44 '';
45
46 pythonRemoveDeps = [ "ruff" ];
47
48 nativeBuildInputs = [
49 hatchling
50 pythonRelaxDepsHook
51 ];
52
53 buildInputs = [ pytest ];
54
55 propagatedBuildInputs = [ black ];
56
57 nativeCheckInputs = [ pytestCheckHook ];
58
59 pythonImportsCheck = [ "pytest_examples" ];
60
61 disabledTests = [
62 # Test fails with latest ruff v0.1.2
63 # See https://github.com/pydantic/pytest-examples/issues/26
64 "test_ruff_error"
65 ];
66
67 meta = with lib; {
68 description = "Pytest plugin for testing examples in docstrings and markdown files";
69 homepage = "https://github.com/pydantic/pytest-examples";
70 changelog = "https://github.com/pydantic/pytest-examples/releases/tag/v${version}";
71 license = licenses.mit;
72 maintainers = with maintainers; [ fab ];
73 };
74}