Skip to content

Commit

Permalink
Fixed raising TypeError instead of ValueError when there is an invali…
Browse files Browse the repository at this point in the history
…d type.
  • Loading branch information
Sai-Suraj-27 authored and cdecker committed Feb 8, 2024
1 parent a005ec1 commit a35006e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contrib/msggen/msggen/gen/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def gen_field(field):
elif isinstance(field, PrimitiveField):
return gen_primitive(field)
else:
raise ValueError(f"Unmanaged type {field}")
raise TypeError(f"Unmanaged type {field}")


def gen_enum(e):
Expand Down
4 changes: 2 additions & 2 deletions contrib/pyln-client/pyln/client/gossmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __eq__(self, other):

def __lt__(self, other):
if not isinstance(other, GossmapNodeId):
raise ValueError(f"Cannot compare GossmapNodeId with {type(other)}")
raise TypeError(f"Cannot compare GossmapNodeId with {type(other)}")
return self.nodeid.__lt__(other.nodeid) # yes, that works

def __hash__(self):
Expand Down Expand Up @@ -268,7 +268,7 @@ def __eq__(self, other):

def __lt__(self, other):
if not isinstance(other, GossmapNode):
raise ValueError(f"Cannot compare GossmapNode with {type(other)}")
raise TypeError(f"Cannot compare GossmapNode with {type(other)}")
return self.node_id.__lt__(other.node_id)

def __hash__(self):
Expand Down
2 changes: 1 addition & 1 deletion contrib/pyln-client/pyln/client/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def call(self, method, payload=None, cmdprefix=None, filter=None):
sock.close()

if not isinstance(resp, dict):
raise ValueError("Malformed response, response is not a dictionary %s." % resp)
raise TypeError("Malformed response, response is not a dictionary %s." % resp)
elif "error" in resp:
raise RpcError(method, payload, resp['error'])
elif "result" not in resp:
Expand Down
4 changes: 2 additions & 2 deletions contrib/pyln-client/pyln/client/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,14 +949,14 @@ def _init(self, options: Dict[str, JSONType],
def verify_str(d: Dict[str, JSONType], key: str) -> str:
v = d.get(key)
if not isinstance(v, str):
raise ValueError("Wrong argument to init: expected {key} to be"
raise TypeError("Wrong argument to init: expected {key} to be"
" a string, got {v}".format(key=key, v=v))
return v

def verify_bool(d: Dict[str, JSONType], key: str) -> bool:
v = d.get(key)
if not isinstance(v, bool):
raise ValueError("Wrong argument to init: expected {key} to be"
raise TypeError("Wrong argument to init: expected {key} to be"
" a bool, got {v}".format(key=key, v=v))
return v

Expand Down
2 changes: 1 addition & 1 deletion contrib/pyln-proto/pyln/proto/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, innerkey):
)

elif not isinstance(innerkey, coincurve.keys.PublicKey):
raise ValueError(
raise TypeError(
"Key must either be bytes or coincurve.keys.PublicKey"
)
self.key = innerkey
Expand Down

0 comments on commit a35006e

Please sign in to comment.