Fix mypy problem after mypy 0.800 upgrade

This commit is contained in:
Matthias 2021-02-28 10:56:51 +01:00
parent 94cab4ed71
commit aba034ff40
2 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,5 @@
from datetime import date, datetime
from typing import Any, Dict, List, Optional, TypeVar, Union
from typing import Any, Dict, List, Optional, Union
from pydantic import BaseModel
@ -205,7 +205,8 @@ class TradeResponse(BaseModel):
trades_count: int
ForceBuyResponse = TypeVar('ForceBuyResponse', TradeSchema, StatusMsg)
class ForceBuyResponse(BaseModel):
__root__: Union[TradeSchema, StatusMsg]
class LockModel(BaseModel):
@ -267,7 +268,8 @@ class PlotConfig_(BaseModel):
subplots: Optional[Dict[str, Any]]
PlotConfig = TypeVar('PlotConfig', PlotConfig_, Dict)
class PlotConfig(BaseModel):
__root__: Union[PlotConfig_, Dict]
class StrategyListResponse(BaseModel):

View File

@ -111,9 +111,9 @@ def forcebuy(payload: ForceBuyPayload, rpc: RPC = Depends(get_rpc)):
trade = rpc._rpc_forcebuy(payload.pair, payload.price)
if trade:
return trade.to_json()
return {'__root__': trade.to_json()}
else:
return {"status": f"Error buying pair {payload.pair}."}
return {'__root__': {"status": f"Error buying pair {payload.pair}."}}
@router.post('/forcesell', response_model=ResultMsg, tags=['trading'])
@ -183,7 +183,7 @@ def pair_history(pair: str, timeframe: str, timerange: str, strategy: str,
@router.get('/plot_config', response_model=PlotConfig, tags=['candle data'])
def plot_config(rpc: RPC = Depends(get_rpc)):
return rpc._rpc_plot_config()
return {'__root__': rpc._rpc_plot_config()}
@router.get('/strategies', response_model=StrategyListResponse, tags=['strategy'])