Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • DuniterPy DuniterPy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 39
    • Issues 39
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • clients
  • python
  • DuniterPyDuniterPy
  • Issues
  • #95
Closed
Open
Created Jun 09, 2019 by Vincent Texier@vtexierOwner

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.

Edited May 09, 2021 by Moul
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking