Page MenuHomeSoftware Heritage

Give model and swhid objects a nicer repr()
ClosedPublic

Authored by vlorentz on Nov 4 2021, 4:36 PM.

Details

Summary
  1. hashes are now repr()ed as hash_to_bytes("1234...") instead of b"\x12\x34..."`
  2. SWHID objects are now repr()ed as CoreSWHID.from_string('swh:1:...:1234...') instead of CoreSWHID(scheme='swh', version='1', object_type=..., object_id=b'\x12\x34')
  3. enums are now repr()ed as MyEnum.NAME instead of "<MyEnum.NAME: 'value'>`

Thanks to these three changes, using repr() on a model object now prints
a string that can be pasted directly in a .py file to write a new
test case.

Diff Detail

Repository
rDMOD Data model
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 24886
Build 38877: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 38876: arc lint + arc unit

Event Timeline

Build has FAILED

Patch application report for D6610 (id=24006)

Rebasing onto 916627e1b5...

Current branch diff-target is up to date.
Changes applied before test
commit 4aade47bc23a27670fb378c18754762a915b001a
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 4 16:32:35 2021 +0100

    Give model and swhid objects a nicer repr()
    
    1. hashes are now repr()ed as `hash_to_bytes("1234...")` instead of b"\x12\x34..."`
    2. SWHID objects are now repr()ed as `CoreSWHID.from_string('swh:1:...:1234...')`
       instead of `CoreSWHID(scheme='swh', version='1', object_type=..., object_id=b'\x12\x34')`
    3. enums are now repr()ed as `MyEnum.NAME` instead of "<MyEnum.NAME: 'value'>`
    
    Thanks to these three changes, using repr() on a model object now prints
    a string that can be pasted directly in a `.py` file to write a new
    test case.

Link to build: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/397/
See console output for more information: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/397/console

Harbormaster returned this revision to the author for changes because remote builds failed.Nov 4 2021, 4:38 PM
Harbormaster failed remote builds in B24879: Diff 24006!

Build has FAILED

Patch application report for D6610 (id=24011)

Rebasing onto 916627e1b5...

Current branch diff-target is up to date.
Changes applied before test
commit f2a5589142ef63be4796616fa576c5e4f20432ae
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 4 16:32:35 2021 +0100

    Give model and swhid objects a nicer repr()
    
    1. hashes are now repr()ed as `hash_to_bytes("1234...")` instead of b"\x12\x34..."`
    2. SWHID objects are now repr()ed as `CoreSWHID.from_string('swh:1:...:1234...')`
       instead of `CoreSWHID(scheme='swh', version='1', object_type=..., object_id=b'\x12\x34')`
    3. enums are now repr()ed as `MyEnum.NAME` instead of "<MyEnum.NAME: 'value'>`
    
    Thanks to these three changes, using repr() on a model object now prints
    a string that can be pasted directly in a `.py` file to write a new
    test case.

Link to build: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/398/
See console output for more information: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/398/console

Harbormaster returned this revision to the author for changes because remote builds failed.Nov 4 2021, 6:16 PM
Harbormaster failed remote builds in B24884: Diff 24011!

Build is green

Patch application report for D6610 (id=24013)

Rebasing onto 916627e1b5...

Current branch diff-target is up to date.
Changes applied before test
commit 331d3c840936de44a7d56b7a385f1c4e762bdacb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 4 16:32:35 2021 +0100

    Give model and swhid objects a nicer repr()
    
    1. hashes are now repr()ed as `hash_to_bytes("1234...")` instead of b"\x12\x34..."`
    2. SWHID objects are now repr()ed as `CoreSWHID.from_string('swh:1:...:1234...')`
       instead of `CoreSWHID(scheme='swh', version='1', object_type=..., object_id=b'\x12\x34')`
    3. enums are now repr()ed as `MyEnum.NAME` instead of "<MyEnum.NAME: 'value'>`
    
    Thanks to these three changes, using repr() on a model object now prints
    a string that can be pasted directly in a `.py` file to write a new
    test case.

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

Build has FAILED

Patch application report for D6610 (id=24014)

Rebasing onto 916627e1b5...

Current branch diff-target is up to date.
Changes applied before test
commit 03ef41c6c19c725009a24d4cbf50e4d6117e0afd
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 4 16:32:35 2021 +0100

    Give model and swhid objects a nicer repr()
    
    1. hashes are now repr()ed as `hash_to_bytes("1234...")` instead of b"\x12\x34..."`
    2. SWHID objects are now repr()ed as `CoreSWHID.from_string('swh:1:...:1234...')`
       instead of `CoreSWHID(scheme='swh', version='1', object_type=..., object_id=b'\x12\x34')`
    3. enums are now repr()ed as `MyEnum.NAME` instead of "<MyEnum.NAME: 'value'>`
    
    Thanks to these three changes, using repr() on a model object now prints
    a string that can be pasted directly in a `.py` file to write a new
    test case.

Link to build: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/400/
See console output for more information: https://jenkins.softwareheritage.org/job/DMOD/job/tests-on-diff/400/console

fix compat with python <3.9

Build is green

Patch application report for D6610 (id=24015)

Rebasing onto 916627e1b5...

Current branch diff-target is up to date.
Changes applied before test
commit 2ffe5dba840144b71559d880e2cd8bca4d9d4afb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Thu Nov 4 16:32:35 2021 +0100

    Give model and swhid objects a nicer repr()
    
    1. hashes are now repr()ed as `hash_to_bytes("1234...")` instead of b"\x12\x34..."`
    2. SWHID objects are now repr()ed as `CoreSWHID.from_string('swh:1:...:1234...')`
       instead of `CoreSWHID(scheme='swh', version='1', object_type=..., object_id=b'\x12\x34')`
    3. enums are now repr()ed as `MyEnum.NAME` instead of "<MyEnum.NAME: 'value'>`
    
    Thanks to these three changes, using repr() on a model object now prints
    a string that can be pasted directly in a `.py` file to write a new
    test case.

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

This revision is now accepted and ready to land.Nov 8 2021, 11:50 AM