Skip to content

Commit

Permalink
Use is instead of ==
Browse files Browse the repository at this point in the history
  • Loading branch information
irenedea committed Oct 11, 2024
1 parent 71d3c6d commit 4d5d252
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/callbacks/test_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def get_default_value(
tpe: type,
inspected_param: typing.Optional[inspect.Parameter],
):
if typing.get_origin(tpe) == typing.Union:
if typing.get_origin(tpe) is typing.Union:
args = typing.get_args(tpe)
return get_default_value(param, args[0], None)
elif typing.get_origin(tpe) == list or typing.get_origin(tpe) == list:
elif typing.get_origin(tpe) is list or typing.get_origin(tpe) is list:
return []
elif typing.get_origin(tpe) == dict or typing.get_origin(tpe) == dict:
elif typing.get_origin(tpe) is dict or typing.get_origin(tpe) is dict:
return {}
elif tpe is int:
return 0
Expand All @@ -47,9 +47,9 @@ def get_default_value(
return {}
elif tpe is list:
return []
elif inspected_param is not None and tpe == typing.Any and inspected_param.kind == inspect.Parameter.VAR_KEYWORD:
elif inspected_param is not None and tpe is typing.Any and inspected_param.kind is inspect.Parameter.VAR_KEYWORD:
return None
elif inspected_param is not None and tpe == typing.Any and inspected_param.kind == inspect.Parameter.VAR_POSITIONAL:
elif inspected_param is not None and tpe is typing.Any and inspected_param.kind is inspect.Parameter.VAR_POSITIONAL:
return None
else:
raise ValueError(f'Unsupported type: {tpe} for parameter {param}')
Expand Down

0 comments on commit 4d5d252

Please sign in to comment.