Page MenuHomeSoftware Heritage

checks: Add type annotation to extra_validator
ClosedPublic

Authored by vlorentz on Mar 21 2022, 10:37 AM.

Details

Summary

I'll put this diff on hold while waiting for an answer on https://github.com/sissaschool/xmlschema/issues/291

Diff Detail

Repository
rDDEP Push deposit
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 D7397 (id=26728)

Could not rebase; Attempt merge onto 6f37ab6eb7...

Merge made by the 'recursive' strategy.
 swh/deposit/api/checks.py            | 105 ++++++++++++-
 swh/deposit/tests/api/test_checks.py | 292 ++++++++++++++++++++++++++++++++++-
 swh/deposit/tests/cli/test_client.py |   4 +-
 swh/deposit/xsd/codemeta.xsd         |  45 +++++-
 4 files changed, 430 insertions(+), 16 deletions(-)
Changes applied before test
commit d1bb747d7c2a519bd6c4e5f32024878577fd0c66
Merge: 6f37ab6e 0f15094a
Author: Jenkins user <jenkins@localhost>
Date:   Mon Mar 21 09:37:20 2022 +0000

    Merge branch 'diff-target' into HEAD

commit 0f15094a363147801eebfcd515a9e7d17da9e87c
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Mon Mar 21 10:36:31 2022 +0100

    checks: Add type annotation to extra_validator

commit 3a101e67c1a41af2fe84943a8934a694fda23e04
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Mar 8 17:40:42 2022 +0100

    Allow chardata in <codemeta:affiliation>, to be compatible with existing metadata
    
    Manually validate <codemeta:affiliation>. Unfortunately, this cannot be
    validated by codemeta.xsd, because Codemeta has conflicting requirements:
    1. https://codemeta.github.io/terms/ requires it to be Text (represented
       by simple content), but
    2. https://doi.org/10.5063/SCHEMA/CODEMETA-2.0 requires it to be an
       Organization (represented by complex content)
    
    See https://github.com/codemeta/codemeta/pull/239 for a discussion about
    this issue.

commit 87744c57b2d8900e6000e504c567f1a5d22bf31d
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Mar 8 16:15:06 2022 +0100

    Add support for YYYY and YYYY-MM as date formats
    
    They are allowed by ISO8601, via schema.org, via codemeta; but not by XML Schema's
    date format.

commit 64efae98071a0b9c9e01bbbcb18c9e26b8230379
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Mon Feb 28 15:15:06 2022 +0100

    Add more Person fields to the schema

commit 2ec5a89af955992f5c7dbbd63f3ee63573b47a03
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Mon Feb 28 12:23:07 2022 +0100

    Add more simpletypes to the schema.

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

Build is green

Patch application report for D7397 (id=26733)

Could not rebase; Attempt merge onto 6f37ab6eb7...

Updating 6f37ab6e..864e441c
Fast-forward
 swh/deposit/api/checks.py            | 105 ++++++++++++-
 swh/deposit/tests/api/test_checks.py | 292 ++++++++++++++++++++++++++++++++++-
 swh/deposit/tests/cli/test_client.py |   4 +-
 swh/deposit/xsd/codemeta.xsd         |  45 +++++-
 4 files changed, 430 insertions(+), 16 deletions(-)
Changes applied before test
commit 864e441c4f91bfedfaec9dbb1acdcd17fa7d1c82
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Mon Mar 21 10:36:31 2022 +0100

    checks: Add type annotation to extra_validator

commit dcae516085b6260cb60c029105e755e9e7cc27b4
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Mar 8 17:40:42 2022 +0100

    Allow chardata in <codemeta:affiliation>, to be compatible with existing metadata
    
    Manually validate <codemeta:affiliation>. Unfortunately, this cannot be
    validated by codemeta.xsd, because Codemeta has conflicting requirements:
    1. https://codemeta.github.io/terms/ requires it to be Text (represented
       by simple content), but
    2. https://doi.org/10.5063/SCHEMA/CODEMETA-2.0 requires it to be an
       Organization (represented by complex content)
    
    See https://github.com/codemeta/codemeta/pull/239 for a discussion about
    this issue.

commit 2c5840c859667ba673d1f00204b95b0ca6f4db0b
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Mar 8 16:15:06 2022 +0100

    Add support for YYYY and YYYY-MM as date formats
    
    They are allowed by ISO8601, via schema.org, via codemeta; but not by XML Schema's
    date format.

commit 136016c2f60fb4453525a7d2a457e3e3b8a4f06a
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Mon Feb 28 15:15:06 2022 +0100

    Add more Person fields to the schema

commit 172e8d55f41ae18cff532520abdb701945bde335
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Mon Feb 28 12:23:07 2022 +0100

    Add more simpletypes to the schema.

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

ardumont added inline comments.
swh/deposit/api/checks.py
145

i'm a tad confused at the extra validator you define which yields the error.
Does internally this still raises the error (i guess so)?

douardda added inline comments.
swh/deposit/api/checks.py
145

Same here, I don't get why the type annotation comes with this change of nature of extra_validator (function -> generator)

swh/deposit/api/checks.py
145

because xmlschema expects it to be a generator of xmlschema.XMLSchemaValidationError. Raising instead of generating only worked accidentally.

This revision is now accepted and ready to land.Mar 28 2022, 1:38 PM

Build is green

Patch application report for D7397 (id=26944)

Could not rebase; Attempt merge onto c83df715a3...

Updating c83df715..bb5c6b55
Fast-forward
 swh/deposit/api/checks.py            | 79 ++++++++++++++++++++++++++++++++----
 swh/deposit/tests/api/test_checks.py | 49 ++++++++++++++++++++--
 swh/deposit/xsd/codemeta.xsd         |  5 ++-
 3 files changed, 119 insertions(+), 14 deletions(-)
Changes applied before test
commit bb5c6b55f2e614e3222980fa2f25a1f3dc5e48aa
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Mon Mar 21 10:36:31 2022 +0100

    checks: Add type annotation to extra_validator

commit df04906e6733400194dae2ff5633124416919c47
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Mar 8 17:40:42 2022 +0100

    Allow chardata in <codemeta:affiliation>, to be compatible with existing metadata
    
    Manually validate <codemeta:affiliation>. Unfortunately, this cannot be
    validated by codemeta.xsd, because Codemeta has conflicting requirements:
    1. https://codemeta.github.io/terms/ requires it to be Text (represented
       by simple content), but
    2. https://doi.org/10.5063/SCHEMA/CODEMETA-2.0 requires it to be an
       Organization (represented by complex content)
    
    See https://github.com/codemeta/codemeta/pull/239 for a discussion about
    this issue.

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