-
Notifications
You must be signed in to change notification settings - Fork 27
Description
In get_object_state, we already do this:
if hasattr(obj, "__getnewargs_ex__"):
args = obj.__getnewargs_ex__()
elif hasattr(obj, "__getnewargs__"):
args = obj.__getnewargs__()
else:
args = None
...
if args is None:
return state
else:
return args, stateWhy do we do this? The state is unnecessary when we have args, or not? When __getnewargs__ or __getnewargs_ex__ is implemented, this should cover the complete state of the object.
What cases do we currently have that actually use __getnewargs__/__getnewargs_ex__? I think this is quite rare, or maybe even non-existent?
Note, I currently have a case, where I implemented __getnewargs_ex__ for some own class, and I was confused that Sisyphus apparently anyway checks the other state.
I implemented __getnewargs_ex__ in a way that should be quite stable w.r.t. the hash, however, the internal object state might change in the future. So that is why I actually would want that Sisyphus only considers the __getnewargs_ex__ output when the object has this function.
The main question is if we have any hashes which would break now when we change this. The code in get_object_state would basically change to this:
if hasattr(obj, "__getnewargs_ex__"):
return obj.__getnewargs_ex__()
elif hasattr(obj, "__getnewargs__"):
return obj.__getnewargs__()
...
return state