chia-blockchain
chia-blockchain copied to clipboard
fix hinting around DaemonProxy._get()
I started looking around this due to the example exception in https://github.com/Chia-Network/chia-blockchain/pull/12459. Anyways, .response_dict
was hinted with Any
for values which caused the hinting in ._get()
to be roughly disabled in terms of the return value thus missing the fact the return type was lacking the Optional
aspect. I haven't dug through the remaining issues but instead just left them broken for the record in the build logs here, and copied below.
Jul 17 20:54:19 fullnode chia_wallet[1432335]: 2022-07-17T20:54:19.142 wallet chia.rpc.util : WARNING Error while handling message: Traceback (most recent call last):
Jul 17 20:54:19 fullnode chia_wallet[1432335]: File "/farm/chia-blockchain/chia/rpc/wallet_rpc_api.py", line 221, in get_public_keys
Jul 17 20:54:19 fullnode chia_wallet[1432335]: sk.get_g1().get_fingerprint() for (sk, seed) in await self.service.keychain_proxy.get_all_private_keys()
Jul 17 20:54:19 fullnode chia_wallet[1432335]: File "/farm/chia-blockchain/chia/daemon/keychain_proxy.py", line 185, in get_all_private_keys
Jul 17 20:54:19 fullnode chia_wallet[1432335]: response, success = await self.get_response_for_request("get_all_private_keys", {})
Jul 17 20:54:19 fullnode chia_wallet[1432335]: File "/farm/chia-blockchain/chia/daemon/keychain_proxy.py", line 93, in get_response_for_request
Jul 17 20:54:19 fullnode chia_wallet[1432335]: success = response["data"].get("success", False)
Jul 17 20:54:19 fullnode chia_wallet[1432335]: TypeError: 'NoneType' object is not subscriptable
Jul 17 20:54:19 fullnode chia_wallet[1432335]: The above exception was the direct cause of the following exception:
Jul 17 20:54:19 fullnode chia_wallet[1432335]: Traceback (most recent call last):
Jul 17 20:54:19 fullnode chia_wallet[1432335]: File "/farm/chia-blockchain/chia/rpc/util.py", line 16, in inner
Jul 17 20:54:19 fullnode chia_wallet[1432335]: res_object = await f(request_data)
Jul 17 20:54:19 fullnode chia_wallet[1432335]: File "/farm/chia-blockchain/chia/rpc/wallet_rpc_api.py", line 226, in get_public_keys
Jul 17 20:54:19 fullnode chia_wallet[1432335]: raise Exception(
Jul 17 20:54:19 fullnode chia_wallet[1432335]: Exception: Error while getting keys. If the issue persists, restart all services. Original error: TypeError: 'NoneType' object is not subscriptable
chia/daemon/client.py:94: error: Incompatible return value type (got "Optional[WsRpcMessage]", expected "WsRpcMessage") [return-value]
chia/daemon/client.py:100: error: Incompatible return value type (got "Optional[WsRpcMessage]", expected "WsRpcMessage") [return-value]
chia/daemon/client.py:106: error: Incompatible return value type (got "Optional[WsRpcMessage]", expected "WsRpcMessage") [return-value]
chia/daemon/client.py:112: error: Value of type "Optional[WsRpcMessage]" is not indexable [index]
chia/daemon/client.py:113: error: Value of type "Optional[WsRpcMessage]" is not indexable [index]
chia/daemon/client.py:120: error: Value of type "Optional[WsRpcMessage]" is not indexable [index]
chia/daemon/client.py:121: error: Value of type "Optional[WsRpcMessage]" is not indexable [index]
chia/daemon/client.py:128: error: Incompatible return value type (got "Optional[WsRpcMessage]", expected "WsRpcMessage") [return-value]
chia/daemon/client.py:133: error: Incompatible types in assignment (expression has type "Optional[WsRpcMessage]", variable has type "WsRpcMessage") [assignment]
chia/daemon/client.py:139: error: Incompatible return value type (got "Optional[WsRpcMessage]", expected "WsRpcMessage") [return-value]
chia/daemon/client.py:149: error: Incompatible return value type (got "Optional[WsRpcMessage]", expected "WsRpcMessage") [return-value]
chia/daemon/keychain_proxy.py:93: error: Value of type "Optional[WsRpcMessage]" is not indexable [index]
chia/daemon/keychain_proxy.py:94: error: Incompatible return value type (got "Tuple[Optional[WsRpcMessage], Any]", expected "Tuple[WsRpcMessage, bool]") [return-value]
Found 13 errors in 2 files (checked 637 source files)
Draft for:
- [ ] Fixing the issues.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
Conflicts have been resolved. A maintainer will review the pull request shortly.