Page MenuHomeSoftware Heritage

model: Add a check() method to model objects
ClosedPublic

Authored by vlorentz on Dec 8 2021, 5:21 PM.

Details

Summary

It calls attr.validate() (which calls the validators), and recomputes
the hash of HashableObject instances.

A future commit will also make it check the raw_manifest attribute
when relevant

Depends on D6798.

Diff Detail

Repository
rDMOD Data model
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D6799 (id=24648)

Could not rebase; Attempt merge onto c32290481c...

Updating c322904..59ed64b
Fast-forward
 swh/model/model.py            | 39 ++++++++++++++++++++++++++-------------
 swh/model/tests/test_model.py | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 13 deletions(-)
Changes applied before test
commit 59ed64b08cd42c5af988b402f5948b077a5cb296
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:24:38 2021 +0100

    model: Add a check() method to model objects
    
    It calls attr.validate() (which calls the validators), and recomputes
    the hash of HashableObject instances.
    
    A future commit will also make it check the raw_manifest attribute
    when relevant

commit 5eb65393af220b3e52f83f34bd27af9d0047cbf2
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:20:38 2021 +0100

    model: Deduplicate calls to hashlib.
    
    It's just simpler this way

commit 2d0105b8413064db60aaa0802a45b0fad8b12d25
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Dec 8 16:17:40 2021 +0100

    model: Add support for None to the type checker
    
    For the sake of completeness (a future commit may depend on it).

See https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/425/ for more details.

anlambert added a subscriber: anlambert.

Looks good to me.

This revision is now accepted and ready to land.Dec 8 2021, 5:27 PM