Skip to content

Commit 2d140ba

Browse files
hackerkidrishig
authored andcommitted
billing: Cast return value of _mock_stripe to CallableT.
Without the cast mypy raises the following error: Incompatible return value type (got "Callable[..., Any]", expected "CallableT") This is a known issue: python/mypy#1927
1 parent 20c41f3 commit 2d140ba

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

@@ -173,8 +173,8 @@ def normalize_fixture_data(decorated_function: CallableT) -> None: # nocoverage
173173
f.write(file_content)
174174

175175
def mock_stripe(*mocked_function_names: str,
176-
generate: Optional[bool]=None) -> Callable[[CallableT], Callable[..., Any]]:
177-
def _mock_stripe(decorated_function: CallableT) -> Callable[..., Any]:
176+
generate: Optional[bool]=None) -> Callable[[CallableT], CallableT]:
177+
def _mock_stripe(decorated_function: CallableT) -> CallableT:
178178
generate_fixture = generate
179179
if generate_fixture is None:
180180
generate_fixture = GENERATE_STRIPE_FIXTURES
@@ -194,7 +194,7 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
194194
if generate_fixture: # nocoverage
195195
normalize_fixture_data(decorated_function)
196196
return val
197-
return wrapped
197+
return cast(CallableT, wrapped)
198198
return _mock_stripe
199199

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

0 commit comments

Comments
 (0)