mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	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: https://github.com/python/mypy/issues/1927
This commit is contained in:
		@@ -5,7 +5,7 @@ import operator
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import sys
 | 
					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 ujson
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -173,8 +173,8 @@ def normalize_fixture_data(decorated_function: CallableT) -> None:  # nocoverage
 | 
				
			|||||||
            f.write(file_content)
 | 
					            f.write(file_content)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def mock_stripe(*mocked_function_names: str,
 | 
					def mock_stripe(*mocked_function_names: str,
 | 
				
			||||||
                generate: Optional[bool]=None) -> Callable[[CallableT], Callable[..., Any]]:
 | 
					                generate: Optional[bool]=None) -> Callable[[CallableT], CallableT]:
 | 
				
			||||||
    def _mock_stripe(decorated_function: CallableT) -> Callable[..., Any]:
 | 
					    def _mock_stripe(decorated_function: CallableT) -> CallableT:
 | 
				
			||||||
        generate_fixture = generate
 | 
					        generate_fixture = generate
 | 
				
			||||||
        if generate_fixture is None:
 | 
					        if generate_fixture is None:
 | 
				
			||||||
            generate_fixture = GENERATE_STRIPE_FIXTURES
 | 
					            generate_fixture = GENERATE_STRIPE_FIXTURES
 | 
				
			||||||
@@ -194,7 +194,7 @@ def mock_stripe(*mocked_function_names: str,
 | 
				
			|||||||
            if generate_fixture:  # nocoverage
 | 
					            if generate_fixture:  # nocoverage
 | 
				
			||||||
                normalize_fixture_data(decorated_function)
 | 
					                normalize_fixture_data(decorated_function)
 | 
				
			||||||
            return val
 | 
					            return val
 | 
				
			||||||
        return wrapped
 | 
					        return cast(CallableT, wrapped)
 | 
				
			||||||
    return _mock_stripe
 | 
					    return _mock_stripe
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# A Kandra is a fictional character that can become anything. Used as a
 | 
					# A Kandra is a fictional character that can become anything. Used as a
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user