Current design with edit()-contextmanager is quite nice to use... but leaves almost all edit()-implementation complexity to the concrete repository class (in this code base GitRepository). There is an alternative design which could possibly hide that complexity inside librepo Repository (which I imagine could live in python-tuf):
don't require the concrete class to implement edit() contextmanager at all
instead require
method Repository.open(role: str) -> RoleDescriptor: this opens the roles metadata for editing
method close() (in Repository or the descriptor class): this saves roles metadata to storage. While doing that it manages expiry and version.
now Repository can implement the edit() contextmanager using open() and close()
Current design with edit()-contextmanager is quite nice to use... but leaves almost all edit()-implementation complexity to the concrete repository class (in this code base GitRepository). There is an alternative design which could possibly hide that complexity inside librepo Repository (which I imagine could live in python-tuf):
Repository.open(role: str) -> RoleDescriptor
: this opens the roles metadata for editingclose()
(in Repository or the descriptor class): this saves roles metadata to storage. While doing that it manages expiry and version.