Skip to content

Commit

Permalink
billing: Cast return value of _mock_stripe to CallableT.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hackerkid committed Nov 12, 2018
1 parent b6c0ccb commit 1479342
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions corporate/tests/test_stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import re
import sys
from typing import Any, Callable, Dict, List, Optional, TypeVar, Tuple
from typing import Any, Callable, Dict, List, Optional, TypeVar, Tuple, cast
import ujson
import json

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

def mock_stripe(*mocked_function_names: str,
generate: Optional[bool]=None) -> Callable[[CallableT], Callable[..., Any]]:
def _mock_stripe(decorated_function: CallableT) -> Callable[..., Any]:
generate: Optional[bool]=None) -> Callable[[CallableT], CallableT]:
def _mock_stripe(decorated_function: CallableT) -> CallableT:
generate_fixture = generate
if generate_fixture is None:
generate_fixture = GENERATE_STRIPE_FIXTURES
Expand All @@ -215,7 +215,7 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
if generate_fixture: # nocoverage
normalize_fixtures(decorated_function)
return val
return wrapped
return cast(CallableT, wrapped)
return _mock_stripe

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

0 comments on commit 1479342

Please sign in to comment.