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 rev = "refs/tags/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 ] ++ lib.optionals (pythonAtLeast "3.10") [ "test_multiple_decorators" ];
53
54 pythonImportsCheck = [ "slowapi" ];
55
56 meta = with lib; {
57 description = "Python library for API rate limiting";
58 homepage = "https://github.com/laurentS/slowapi";
59 changelog = "https://github.com/laurentS/slowapi/blob/v${version}/CHANGELOG.md";
60 license = with licenses; [ mit ];
61 maintainers = with maintainers; [ fab ];
62 };
63}