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