diff options
| author | Павел Жуков <33721692+LeaveMyYard@users.noreply.github.com> | 2023-05-16 11:39:02 +0300 |
|---|---|---|
| committer | Павел Жуков <33721692+LeaveMyYard@users.noreply.github.com> | 2023-05-16 11:39:02 +0300 |
| commit | d9ec57e6ef45c98c697dbfdf784e993fd9343fd9 (patch) | |
| tree | 6b90f4a9f17b65c1ff54234228b46eaec81654e0 /robusta_krr | |
| parent | 7bd0c5298e233248e17e6c0cf9ac0e6d7e30ca73 (diff) | |
Fix mypy error in strategies.py
Diffstat (limited to 'robusta_krr')
| -rw-r--r-- | robusta_krr/core/abstract/strategies.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/robusta_krr/core/abstract/strategies.py b/robusta_krr/core/abstract/strategies.py index c175bd6..ed08627 100644 --- a/robusta_krr/core/abstract/strategies.py +++ b/robusta_krr/core/abstract/strategies.py @@ -12,7 +12,7 @@ from robusta_krr.core.models.result import K8sObjectData, ResourceType from robusta_krr.utils.display_name import add_display_name -Self = TypeVar("Self", bound="ResourceRecommendation") +SelfRR = TypeVar("SelfRR", bound="ResourceRecommendation") class ResourceRecommendation(pd.BaseModel): @@ -20,8 +20,8 @@ class ResourceRecommendation(pd.BaseModel): limit: Optional[float] @classmethod - def undefined(cls: type[Self]) -> Self: - return cls(request=Decimal('NaN'), limit=Decimal('NaN')) + def undefined(cls: type[SelfRR]) -> SelfRR: + return cls(request=float('NaN'), limit=float('NaN')) class StrategySettings(pd.BaseModel): @@ -46,7 +46,7 @@ ResourceHistoryData = dict[str, ArrayNx2] HistoryData = dict[ResourceType, ResourceHistoryData] RunResult = dict[ResourceType, ResourceRecommendation] -Self = TypeVar("Self", bound="BaseStrategy") +SelfBS = TypeVar("SelfBS", bound="BaseStrategy") @add_display_name(postfix="Strategy") @@ -66,7 +66,7 @@ class BaseStrategy(abc.ABC, Generic[_StrategySettings]): """Run the strategy to calculate the recommendation""" @classmethod - def find(cls: type[Self], name: str) -> type[Self]: + def find(cls: type[SelfBS], name: str) -> type[SelfBS]: """Get a strategy from its name.""" strategies = cls.get_all() @@ -76,7 +76,7 @@ class BaseStrategy(abc.ABC, Generic[_StrategySettings]): raise ValueError(f"Unknown strategy name: {name}. Available strategies: {', '.join(strategies)}") @classmethod - def get_all(cls: type[Self]) -> dict[str, type[Self]]: + def get_all(cls: type[SelfBS]) -> dict[str, type[SelfBS]]: # NOTE: Load default formatters from robusta_krr import strategies as _ # noqa: F401 |
