1{
2 lib,
3 buildPythonPackage,
4 django-stubs,
5 fetchFromGitHub,
6 mypy,
7 py,
8 coreapi,
9 pytest-mypy-plugins,
10 pytestCheckHook,
11 pythonOlder,
12 requests,
13 types-pyyaml,
14 setuptools,
15 types-markdown,
16 types-requests,
17 typing-extensions,
18}:
19
20buildPythonPackage rec {
21 pname = "djangorestframework-stubs";
22 version = "3.16.2";
23 pyproject = true;
24
25 disabled = pythonOlder "3.10";
26
27 src = fetchFromGitHub {
28 owner = "typeddjango";
29 repo = "djangorestframework-stubs";
30 tag = version;
31 hash = "sha256-A6IyRJwuc0eqRtkCHtWN5C5yCMdgxfygqmpHV+/MJhE=";
32 };
33
34 postPatch = ''
35 substituteInPlace pyproject.toml \
36 --replace-fail "<79.0.0" ""
37 '';
38
39 build-system = [ setuptools ];
40
41 dependencies = [
42 django-stubs
43 requests
44 types-pyyaml
45 types-requests
46 typing-extensions
47 ];
48
49 optional-dependencies = {
50 compatible-mypy = [ mypy ] ++ django-stubs.optional-dependencies.compatible-mypy;
51 coreapi = [ coreapi ];
52 markdown = [ types-markdown ];
53 };
54
55 nativeCheckInputs = [
56 py
57 pytest-mypy-plugins
58 pytestCheckHook
59 ]
60 ++ lib.flatten (builtins.attrValues optional-dependencies);
61
62 # Upstream recommends mypy > 1.7 which we don't have yet, thus all tests are failing with 3.14.5 and below
63 doCheck = false;
64
65 pythonImportsCheck = [ "rest_framework-stubs" ];
66
67 meta = with lib; {
68 description = "PEP-484 stubs for Django REST Framework";
69 homepage = "https://github.com/typeddjango/djangorestframework-stubs";
70 changelog = "https://github.com/typeddjango/djangorestframework-stubs/releases/tag/${src.tag}";
71 license = licenses.mit;
72 maintainers = with maintainers; [ ];
73 };
74}