Skip to content

Commit f3d82ae

Browse files
committed
Make protocol runtime checkable, ruff
1 parent 7cf1164 commit f3d82ae

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

async_substrate_interface/async_substrate.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,6 +2967,9 @@ async def get_payment_info(
29672967
if not isinstance(call, GenericCall):
29682968
raise TypeError("'call' must be of type Call")
29692969

2970+
if not isinstance(keypair, Keypair):
2971+
raise TypeError("'keypair' must be of type Keypair")
2972+
29702973
# No valid signature is required for fee estimation
29712974
signature = "0x" + "00" * 64
29722975

async_substrate_interface/const.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
2-
31
# Re-define SS58 format here to remove unnecessary dependencies.
4-
SS58_FORMAT = 42
2+
SS58_FORMAT = 42
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,36 @@
1-
from typing import Awaitable, Protocol, Union, Optional
1+
from typing import Awaitable, Protocol, Union, Optional, runtime_checkable
22

33

4-
__all__: list[str] = [
5-
'Keypair'
6-
]
4+
__all__: list[str] = ["Keypair"]
75

86

97
# For reference only
108
# class KeypairType:
119
# """
1210
# Type of cryptography, used in `Keypair` instance to encrypt and sign data
13-
#
11+
#
1412
# * ED25519 = 0
1513
# * SR25519 = 1
1614
# * ECDSA = 2
17-
#
15+
#
1816
# """
1917
# ED25519 = 0
2018
# SR25519 = 1
2119
# ECDSA = 2
2220

2321

22+
@runtime_checkable
2423
class Keypair(Protocol):
25-
2624
@property
27-
def crypto_type(self) -> int:
28-
...
25+
def crypto_type(self) -> int: ...
2926

3027
@property
31-
def public_key(self) -> Optional[bytes]:
32-
...
28+
def public_key(self) -> Optional[bytes]: ...
3329

3430
@property
35-
def ss58_address(self) -> str:
36-
...
31+
def ss58_address(self) -> str: ...
3732

3833
@property
39-
def ss58_format(self) -> int:
40-
...
34+
def ss58_format(self) -> int: ...
4135

42-
def sign(self, data: Union[bytes, str]) -> Union[bytes, Awaitable[bytes]]:
43-
...
36+
def sign(self, data: Union[bytes, str]) -> Union[bytes, Awaitable[bytes]]: ...

0 commit comments

Comments
 (0)