我具有以下两个功能:
def payment_failed(user: User, charge: Charge, type: str) -> HttpResponse:
# ... do something here
return HttpResponse(status=200)
def payment_canceled(*args):
return payment_failed(*args)
我还想对payment_canceled
函数使用类型提示,但是我不确定哪个版本正确。
版本1:
def payment_canceled(*args) -> payment_failed:
return payment_failed(*args)
版本2:
def payment_canceled(*args) -> HttpResponse:
return payment_failed(*args)
答案 0 :(得分:4)
import AppContainer from './src/Navigation/AppNavigator';
export default class App extends Component {
render() {
console.log(this.props)
return (
<AppContainer />
);
}
}
不返回另一个函数;它调用payment_canceled
并返回它返回的任何内容。第二个是正确的:
payment_failed
如果您确实要返回函数,则可以使用def payment_canceled(*args) -> HttpResponse:
return payment_failed(*args)
模块中的Callable
。
typing