Page MenuHomeSoftware Heritage

Add type annotations on get_storage.
ClosedPublic

Authored by vlorentz on Wed, Jul 29, 3:13 PM.

Details

Summary

The main goal of this commit is to add '-> StorageInterface', so all storage
users automatically get type-checked.

But mypy was whining about the multiple imports, so this commit also
deduplicates the import statements as a side-effect.

Diff Detail

Repository
rDSTO Storage manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz created this revision.Wed, Jul 29, 3:13 PM
ardumont added inline comments.
swh/storage/__init__.py
24

But is this true though?

at least filter/buffer/retry are not per say StorageInterface, aren't they?

ardumont added inline comments.Wed, Jul 29, 3:16 PM
swh/storage/__init__.py
24

I'm doing it heh but i keep having that voice raising in my head saying "lies" ;)

ardumont added inline comments.Wed, Jul 29, 3:18 PM

Build is green

Patch application report for D3640 (id=12820)

Rebasing onto 21b77304a0...

First, rewinding head to replay your work on top of it...
Applying: Add type annotations on get_storage.
Changes applied before test
commit fa45a9b83c0f61547652cfb943441524633e02db
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Jul 29 15:13:04 2020 +0200

    Add type annotations on get_storage.
    
    The main goal of this commit is to add '-> StorageInterface', so all storage
    users automatically get type-checked.
    
    But mypy was whining about the multiple imports, so this commit also
    deduplicates the import statements as a side-effect.

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

vlorentz added inline comments.Wed, Jul 29, 3:33 PM
swh/storage/__init__.py
20

I didn't remove it from get_storage.

24

They behave differently, but their signatures are the same afaik

ardumont added inline comments.Wed, Jul 29, 3:53 PM
swh/storage/__init__.py
20

ah yeah, thanks ;)

24

yes, indeed.
just raising this "concern" to someone else ;)

64

well, might as well type it as well to return a StorageInterface.

vlorentz updated this revision to Diff 12821.Wed, Jul 29, 4:05 PM

add type for get_storage_pipeline.

Build is green

Patch application report for D3640 (id=12821)

Rebasing onto 21b77304a0...

First, rewinding head to replay your work on top of it...
Applying: Add type annotations on get_storage.
Changes applied before test
commit 796cb00681ffca68f5734ea6f0245af3e333e7eb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Jul 29 15:13:04 2020 +0200

    Add type annotations on get_storage.
    
    The main goal of this commit is to add '-> StorageInterface', so all storage
    users automatically get type-checked.
    
    But mypy was whining about the multiple imports, so this commit also
    deduplicates the import statements as a side-effect.

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

ardumont accepted this revision.Wed, Jul 29, 4:21 PM

Thanks.

This revision is now accepted and ready to land.Wed, Jul 29, 4:21 PM
This revision was landed with ongoing or failed builds.Thu, Jul 30, 1:53 PM
This revision was automatically updated to reflect the committed changes.

Build is green

Patch application report for D3640 (id=12851)

Rebasing onto 8cf6efa2e6...

First, rewinding head to replay your work on top of it...
Fast-forwarded diff-target to base-revision-622-D3640.
Changes applied before test

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