Page MenuHomeSoftware Heritage

Accept Sequence[ModelObject] instead of List[ModelObject]
ClosedPublic

Authored by olasd on Apr 9 2020, 2:11 PM.

Details

Summary

The latter is invariant (because List is a mutable type), so it doesn't allow
passing in lists of ModelObject subtypes.

Test Plan

mypy is happy

Diff Detail

Repository
rDJNL Journal infrastructure
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 D2990 (id=10629)

Rebasing onto 893d285adf...

Current branch diff-target is up to date.
Changes applied before test
commit 08348047d28bfd699a827f6a6b0fcf5dc8625aca
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Wed Apr 8 16:50:57 2020 +0200

    Accept Sequence[ModelObject] instead of List[ModelObject]
    
    The latter is invariant (because List is a mutable type), so it doesn't allow
    passing in lists of ModelObject subtypes.

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

This revision is now accepted and ready to land.Apr 9 2020, 2:21 PM

What does it have to do with mutability?

(And it doesn't have to be a sequence, Iterable is enough)

Use Iterable instead of Sequence

Build is green

Patch application report for D2990 (id=10635)

Rebasing onto 893d285adf...

Current branch diff-target is up to date.
Changes applied before test
commit eb4f3626e8f3f6e0cffbc610fdd47e06ddbdac22
Author: Nicolas Dandrimont <nicolas@dandrimont.eu>
Date:   Wed Apr 8 16:50:57 2020 +0200

    write_additions: Accept Iterable[ModelObject] instead of List[ModelObject]
    
    This allows us to pass objects typed as lists of ModelObject subtypes.

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