Skip to content

Commit 1479342

Browse files
committed
billing: Cast return value of _mock_stripe to CallableT.
Without the cast mypy creates the following error. Incompatible return value type (got "Callable[..., Any]", expected "CallableT This is a known issue. python/mypy#1927
1 parent b6c0ccb commit 1479342

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

corporate/tests/test_stripe.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import re
77
import sys
8-
from typing import Any, Callable, Dict, List, Optional, TypeVar, Tuple
8+
from typing import Any, Callable, Dict, List, Optional, TypeVar, Tuple, cast
99
import ujson
1010
import json
1111

@@ -194,8 +194,8 @@ def normalize_fixtures(decorated_function: CallableT) -> None: # nocoverage
194194
f.write(file_content)
195195

196196
def mock_stripe(*mocked_function_names: str,
197-
generate: Optional[bool]=None) -> Callable[[CallableT], Callable[..., Any]]:
198-
def _mock_stripe(decorated_function: CallableT) -> Callable[..., Any]:
197+
generate: Optional[bool]=None) -> Callable[[CallableT], CallableT]:
198+
def _mock_stripe(decorated_function: CallableT) -> CallableT:
199199
generate_fixture = generate
200200
if generate_fixture is None:
201201
generate_fixture = GENERATE_STRIPE_FIXTURES
@@ -215,7 +215,7 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
215215
if generate_fixture: # nocoverage
216216
normalize_fixtures(decorated_function)
217217
return val
218-
return wrapped
218+
return cast(CallableT, wrapped)
219219
return _mock_stripe
220220

221221
# A Kandra is a fictional character that can become anything. Used as a

0 commit comments

Comments
 (0)