Skip to content

Commit f486c12

Browse files
author
Xiao Li
committed
fix types lint
1 parent 41902d4 commit f486c12

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def run(self):
7676
setup(
7777
name="pylibra-beta",
7878
# change to 0.1.YYYYMMDDNN on release
79-
version="0.5.master",
79+
version="0.5.2020091001",
8080
description="",
8181
python_requires=">=3.7",
8282
packages=find_packages("src"),

python/src/pylibra/_jsonrpc_transport.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class GetAccountStateResp:
4444
balances: typing.List[typing.Dict]
4545
sent_events_key: str
4646
received_events_key: str
47-
role: typing.Union[str, typing.Dict]
47+
role: typing.Dict[str, typing.Any]
4848
is_frozen: bool
4949

5050

@@ -160,7 +160,7 @@ def metadata(self) -> bytes:
160160
return bytes.fromhex(self._transaction["script"]["metadata"]) if self.is_p2p else b""
161161

162162
@property
163-
def vm_status(self) -> int:
163+
def vm_status(self) -> typing.Dict[str, typing.Any]:
164164
return self._result["vm_status"]
165165

166166

@@ -178,15 +178,11 @@ def __init__(self, address_hex: str, state: GetAccountStateResp):
178178
for balance_dict in self._state.balances:
179179
self._balances[balance_dict["currency"]] = balance_dict["amount"]
180180

181-
if type(self._state.role) == str:
182-
# For strings returned like "empty", "unknown"
183-
self._role = typing.cast(str, self._state.role)
184-
else:
185-
role_dict = typing.cast(typing.Dict, self._state.role)
186-
if self._state.role["type"] == "parent_vasp":
187-
self._role = ParentVASP(**(role_dict))
188-
elif self._state.role["type"] == "child_vasp":
189-
self._role = ChildVASP(**(role_dict))
181+
role_dict = typing.cast(typing.Dict, self._state.role)
182+
if self._state.role["type"] == "parent_vasp":
183+
self._role = ParentVASP(**(role_dict))
184+
elif self._state.role["type"] == "child_vasp":
185+
self._role = ChildVASP(**(role_dict))
190186

191187
@property
192188
def address(self) -> bytes:

python/src/pylibra/_types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def metadata(self) -> bytes:
178178

179179
@property
180180
@abstractmethod
181-
def vm_status(self) -> int:
181+
def vm_status(self) -> typing.Dict[str, typing.Any]:
182182
raise NotImplementedError()
183183

184184

python/tests/test_lcs.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def test_lcs_e2e() -> None:
1414
print("Testing serialization: ")
1515

1616
obj = libra.Transaction__GenesisTransaction(
17-
libra.WriteSetPayload__Direct(libra.ChangeSet(libra.WriteSet(libra.WriteSetMut(write_set=[])), []))
17+
value=libra.WriteSetPayload__Direct(
18+
value=libra.ChangeSet(
19+
write_set=libra.WriteSet(
20+
value=libra.WriteSetMut(write_set=[])), events=[]))
1821
)
1922
content = lcs.serialize(obj, libra.Transaction)
2023

@@ -68,7 +71,7 @@ def test_stdlib() -> None:
6871
assert isinstance(raw_txn.payload, libra.TransactionPayload__Script)
6972

7073
token = libra.TypeTag__Struct(
71-
libra.StructTag(
74+
value=libra.StructTag(
7275
address=make_address(b"\x00" * 15 + b"\x01"),
7376
module=libra.Identifier("LBR"),
7477
name=libra.Identifier("LBR"),

0 commit comments

Comments
 (0)