Page MenuHomeSoftware Heritage

model: Fix hypothesis integration with attr < 21.3.0
ClosedPublic

Authored by anlambert on Oct 17 2022, 5:30 PM.

Details

Summary

When using attr < 21.3.0, adding field transformer breaks attrs
integration with hypothesis, because attributes transformed with
such function are not casted to generated AttrsClass, but remains
just an list of attributes. This causes error in hypothesis by
raising an AttributeError.

As we use attr 21.2.0 in production and when building debian buster
package, add a workaround for that issue as explained here:
https://github.com/python-attrs/attrs/issues/821.

This fixes debian buster package build for swh-model.

Diff Detail

Repository
rDMOD Data model
Branch
attr-21.2.0-compat
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 32327
Build 50632: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 50631: arc lint + arc unit

Event Timeline

Build is green

Patch application report for D8688 (id=31380)

Rebasing onto 13e7adc3e8...

Current branch diff-target is up to date.
Changes applied before test
commit dd3bab81af296c8ac621213df2345680b53fbd09
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Mon Oct 17 17:22:01 2022 +0200

    model: Fix hypothesis integration with attr < 21.3.0
    
    When using attr < 21.3.0, adding field transformer breaks attrs
    integration with hypothesis, because attributes transformed with
    such function are not casted to generated AttrsClass, but remains
    just an list of attributes. This causes error in hypothesis by
    raising an AttributeError.
    
    As we use attr 21.2.0 in production and when building debian buster
    package, add a workaround for that issue as explained here:
    https://github.com/python-attrs/attrs/issues/821.

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

This revision is now accepted and ready to land.Oct 17 2022, 5:56 PM