Skip to content

Commit aca81f0

Browse files
committed
mypy: unsupported operand type(s) for | in py3.9, rm unused import, fix wrong types
1 parent 30190e6 commit aca81f0

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/aleph/sdk/client/abstract.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020

2121
from aleph_message.models import (
2222
AlephMessage,
23-
InstanceContent,
23+
ExecutableContent,
2424
ItemHash,
2525
ItemType,
2626
MessagesResponse,
2727
MessageType,
2828
Payment,
2929
PostMessage,
30-
ProgramContent,
3130
parse_message,
3231
)
3332
from aleph_message.models.execution.environment import (
@@ -247,7 +246,7 @@ def watch_messages(
247246
@abstractmethod
248247
def get_estimated_price(
249248
self,
250-
content: ProgramContent | InstanceContent,
249+
content: ExecutableContent,
251250
) -> Coroutine[Any, Any, PriceResponse]:
252251
"""
253252
Get Instance/Program content estimated price

src/aleph/sdk/client/http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from aleph_message.models import (
2525
AlephMessage,
2626
Chain,
27-
InstanceContent,
27+
ExecutableContent,
2828
ItemHash,
2929
ItemType,
3030
MessageType,
@@ -460,7 +460,7 @@ async def watch_messages(
460460

461461
async def get_estimated_price(
462462
self,
463-
content: ProgramContent | InstanceContent,
463+
content: ExecutableContent,
464464
) -> PriceResponse:
465465
item_content: str = json.dumps(
466466
content, separators=(",", ":"), default=extended_json_encoder

src/aleph/sdk/exceptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def __init__(
8080
self, token_type: TokenType, required_funds: float, available_funds: float
8181
):
8282
self.token_type = token_type
83-
self.required_funds = displayable_amount(required_funds, decimals=8)
84-
self.available_funds = displayable_amount(available_funds, decimals=8)
83+
self.required_funds = required_funds
84+
self.available_funds = available_funds
8585
super().__init__(
86-
f"Insufficient funds ({self.token_type.value}): required {self.required_funds}, available {self.available_funds}"
86+
f"Insufficient funds ({self.token_type.value}): required {displayable_amount(self.required_funds, decimals=8)}, available {displayable_amount(self.available_funds, decimals=8)}"
8787
)
8888

8989

src/aleph/sdk/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import os
99
import subprocess
1010
from datetime import date, datetime, time
11-
from decimal import ROUND_CEILING, Decimal
11+
from decimal import Decimal
1212
from enum import Enum
1313
from pathlib import Path
1414
from shutil import make_archive
@@ -414,7 +414,7 @@ def safe_getattr(obj, attr, default=None):
414414

415415

416416
def displayable_amount(
417-
amount: str | int | float | Decimal, decimals: Optional[int] = None
417+
amount: Union[str, int, float, Decimal], decimals: Optional[int] = None
418418
) -> str:
419419
"""Returns the amount as a string without unnecessary decimals."""
420420

0 commit comments

Comments
 (0)