chia-blockchain icon indicating copy to clipboard operation
chia-blockchain copied to clipboard

fix hinting around DaemonProxy._get()

Open altendky opened this issue 2 years ago • 3 comments

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.

altendky avatar Jul 17 '22 22:07 altendky

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Aug 05 '22 02:08 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Aug 05 '22 04:08 github-actions[bot]

Conflicts have been resolved. A maintainer will review the pull request shortly.

github-actions[bot] avatar Sep 15 '22 16:09 github-actions[bot]