Remove `signatures` argument from all `__init__()`’s documents subclasses
When we instantiate a Document
instance, or a Document
subclass instance, we do not have the signatures of the document as it is not created yet.
So we can remove the signatures
argument in the __init__()
of Document
and all his subclass.
It will be a big backward compatibility break. But the code will be more logic and simple.
Deprecation first
Deprecation need to be done in a previous release (say %0.60.0 for example).
It will be Deprecated gracefully with warnings, thanks to python deprecation system.
http://www.jaggedverge.com/2016/09/deprecation-warnings-in-python/
To ease the migration, perhaps start by set the argument as Optional with deprecationWarning.
Then remove it in a future version...
Previous thoughts
All documents classes inherit of the Document
class.
The Document
class has a required signatures
parameter which type is List[str]
.
But most of the subclass does not have any signature when creating an instance.
So, when None
is passed, the subclass handle it differently.
See Identity
subclass handling (and the fact that you must provide a None
parameter):
def __init__(
self,
version: int,
currency: str,
pubkey: str,
uid: str,
ts: BlockUID,
signature: Optional[str],
) -> None:
...
if signature:
super().__init__(version, currency, [signature])
else:
super().__init__(version, currency, [])
See Membership
subclass, consider it to be the best way to do it:
def __init__(
self,
version: int,
currency: str,
issuer: str,
membership_ts: BlockUID,
membership_type: str,
uid: str,
identity_ts: BlockUID,
signature: Optional[str] = None,
) -> None:
...
super().__init__(version, currency, [signature] if signature else [])
Here, the signature
parameter is not required, and we prepare a signatures
parameter for the parent Document
class.
We should do it for all subclass of Document
, being careful as some are multi-signature.