1{
2 lib,
3 buildPythonPackage,
4 fastapi,
5 fetchFromGitHub,
6 limits,
7 mock,
8 hiro,
9 httpx,
10 poetry-core,
11 pytestCheckHook,
12 pythonAtLeast,
13 pythonOlder,
14 redis,
15 starlette,
16}:
17
18buildPythonPackage rec {
19 pname = "slowapi";
20 version = "0.1.9";
21 pyproject = true;
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "laurentS";
27 repo = "slowapi";
28 tag = "v${version}";
29 hash = "sha256-R/Mr+Qv22AN7HCDGmAUVh4efU8z4gMIyhC0AuKmxgdE=";
30 };
31
32 nativeBuildInputs = [ poetry-core ];
33
34 propagatedBuildInputs = [
35 limits
36 redis
37 ];
38
39 nativeCheckInputs = [
40 fastapi
41 hiro
42 httpx
43 mock
44 pytestCheckHook
45 starlette
46 ];
47
48 disabledTests = [
49 # AssertionError: Regex pattern 'parameter `request` must be an instance of starlette.requests.Request' does not match 'This portal is not running'.
50 "test_endpoint_request_param_invalid"
51 "test_endpoint_response_param_invalid"
52 # AssertionError: assert '1740326049.9886339' == '1740326049'
53 "test_headers_no_breach"
54 "test_headers_breach"
55 ]
56 ++ lib.optionals (pythonAtLeast "3.10") [ "test_multiple_decorators" ];
57
58 pythonImportsCheck = [ "slowapi" ];
59
60 meta = with lib; {
61 description = "Python library for API rate limiting";
62 homepage = "https://github.com/laurentS/slowapi";
63 changelog = "https://github.com/laurentS/slowapi/blob/v${version}/CHANGELOG.md";
64 license = with licenses; [ mit ];
65 maintainers = with maintainers; [ fab ];
66 };
67}