Page MenuHomeSoftware Heritage

Add type annotations on get_storage.
ClosedPublic

Authored by vlorentz on Jul 29 2020, 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

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?

swh/storage/__init__.py
24

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

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.

swh/storage/__init__.py
19

I didn't remove it from get_storage.

24

They behave differently, but their signatures are the same afaik

swh/storage/__init__.py
19

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.

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.

This revision is now accepted and ready to land.Jul 29 2020, 4:21 PM
This revision was landed with ongoing or failed builds.Jul 30 2020, 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.